Multiple functions by a single switch - Page 2

# Thread: Multiple functions by a single switch – 40 days old

1. 0

## Re: Multiple functions by a single switch

Originally Posted by craig
Four different functions is to have a counter attached and lets say one press does task 1, Second Press does task 2 and so on.
You must de-bounce the switch and have a small delay to stop overlapping.

Regards
Craig
The code in post #4 is what it do!

2. 0

## Re: Multiple functions by a single switch

Thanks.Joseph code worked for me.

I want to add 3 digit thumbwheel switch .Any code for this.
When I enter 333 on thumbwheel switch my counter should stop on 333.

3. 0

## Re: Multiple functions by a single switch

Can you please explain connection of thumbwheel switch? And when to start the counter? When you press a push or something similar.

4. 0

## Re: Multiple functions by a single switch

When I set 111 on thumbwheel switch the counter starts on power on and stops when it reaches 111.pls check photo.IMG_20181113_192813.jpg

5. 0

## Re: Multiple functions by a single switch

I came up with some code, not tested but should work.

Two important things: -

1. Wheel_Value is the value of your thumb wheel. You have to see how to acquire this setting of the thumb wheel and load variable Wheel_Value.
2. A way to start the counting. In my example I assumed a push will trigger the counter.

Code:
```Dim Wheel_Cnt As Word = 0

Main:

Wheel_Cnt = Wheel_Value     ' Wheel value is the thumb wheel set.
' It is up to you how you are going to capture this value

If Switch = 0 Then          ' If switch or push is pressed start counter then

Do                      ' Create a loop
Inc Wheel_Cnt       ' increase Heel_Count
DelayMS 100         ' some delay as required
Loop Until Wheel_Cnt = Wheel_Value ' Redo loop until Wheel_Cnt reac Wheel_Value

GoSub Sub_Rtn           ' goto Sub_Rtn
Wheel_Cnt = 0           ' clear Wheel_Cnt
EndIf                       ' End If...Then instruction

GoTo Main                   ' Repeat Main routine

'========================================================================================

Sub_Rtn:                    ' Sub_Rtn label

' Your code for when the counter reach the thumb wheel value
'
'
'

Return                      ' Return from where it was called

'========================================================================================```

6. 0

## Re: Multiple functions by a single switch

Thanks Joseph,As Iam out of the city,I will definitely try it on Saturday.

7. 0

## Re: Multiple functions by a single switch

Every thing is working fine except decimal point

my decimal code is working fine in 16f877A but not in 16f886

DS3:
GoSub FND
DG3=128 | DG <----- this does not work in 16f886 but working fine in 16f877A

my fuse settings are
;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Device = 16F886

Config1 FOSC_INTRC_NOCLKOUT, WDTE_OFF, PWRTE_OFF, MCLRE_OFF, CP_OFF, CPD_OFF, BOREN_ON, IESO_ON, FCMEN_ON, LVP_OFF, DEBUG_OFF
Config2 BOR4V_BOR40V, WRT_OFF

;**** End of Fuse Configurator Settings ****

8. 0

## Re: Multiple functions by a single switch

As you are simply adding the decimal point try

DG3 = DG + 128

9. 0

## Re: Multiple functions by a single switch

It doesn't work.i tried DS3=128 & DG it worked but it disturb the whole display.Decimal point comes but rest segment doesn't work properly.

10. 0

## Re: Multiple functions by a single switch

11. Which oin of the PIC are you using for the decimal point? Is it set as digital output?