
Thread: Multiple functions by a single switch – 105 days old
-
8th November 2018, 18:25 #1
1Multiple functions by a single switch
Hi,
How can I use multiple function by a single switch.I want to use 4 functions by a single switch.
-
8th November 2018, 18:45 #2
- Join Date
- Jan 2003
- Posts
- 7,597
- Total Downloaded
- 895.24 MB
Thumbs Up Received: 69
Given: 91
0Re: Multiple functions by a single switch
Do you want 4 buttons on one pic pin or 4 functions of 1 button?
Tim
-
8th November 2018, 19:00 #3
0Re: Multiple functions by a single switch
4 functions by a single switch.
-
8th November 2018, 19:57 #4
- Join Date
- Sep 2004
- Posts
- 2,405
- Total Downloaded
- 4.08 GB
Thumbs Up Received: 94
Given: 24
0Re: Multiple functions by a single switch
The following code will go through five different function upon your selection. This was a quick code just to let you think about it. NOT TESTED but should work.
Code:Dim Sele As Byte = 0 Dim Time As Word = 0 '---------------------------------------------------------------------------------------- Main: If But = 0 Then ' If push is pressed then DelayMS 100 ' some debounce delay Inc Sele ' increase Sele Time = 0 ' clear Time If Sele = 5 Then Sele = 0 ' reset counter Sele to 0 if more than 4 EndIf DelayMS 1 ' Delay of 1ms to determine time Inc Time ' Increase Time If Time < 500 Then GoTo Main ' If Time is smaller 500ms then goto Main On Sele GoToL Main , Label_1 , Label_2 , Label_3 , Label_4 GoTo Main ' Goto Main just in case something weird happened '---------------------------------------------------------------------------------------- Label_1: ' This label code goes here GoTo Main '---------------------------------------------------------------------------------------- Label_2: ' This label code goes here GoTo Main '---------------------------------------------------------------------------------------- Label_3: ' This label code goes here GoTo Main '---------------------------------------------------------------------------------------- Label_4: ' This label code goes here GoTo Main '----------------------------------------------------------------------------------------
Sele = 0 will do the Main routine
Sele = 1 will jump to Label_1
Sele = 2 will jump to Label_2
Sele = 3 will jump to Label_3
Sele = 4 will jump to Label_4
If you want to minimise the time the routine jumps to the label change the value of: -
Code:If Time < 500 Then GoTo Main ' If Time is smaller 500ms then goto Main
Regards
Joseph
-
9th November 2018, 08:34 #5
0Re: Multiple functions by a single switch
Hello Amod
You can only read a 0 or a 1 from a Single Pole switch which can only give Two Functions.
Otherwise you could use Four Single Pole Switches
and connect them to a single pin under ADC and then put resistors between the four switches to give different Readings (Voltages) on the ADC
When each switch is pushed, It will give a different Voltage(ADC_Reading).
Then put a Select - Case Loop In to Read the different values and assign each to it's own Gosub routine to get your Four different functions.
Regards
Craig
-
9th November 2018, 14:04 #6
0Re: Multiple functions by a single switch
Screenshot_2018-11-09-18-31-53-568_com.google.android.apps.docs.jpg
I want like this snapshot
-
9th November 2018, 15:03 #7
0Re: Multiple functions by a single switch
Amod
Your Screenshot is a bit small to see clearly. The only thing I can think of if you wan't to use a Single button to do
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
-
9th November 2018, 17:11 #8
- Join Date
- Sep 2010
- Posts
- 1,251
- Total Downloaded
- 2.98 GB
Thumbs Up Received: 77
Given: 39
0Re: Multiple functions by a single switch
I think what he wants is like Joseph suggested: hold the switch down for a short time is one function, a bit longer for the second and so on.
I seem to remember Les describing a single button that you could tap morse code into (a long long time ago) for a security system.
There is a bell push that rings the bell if held down, or opens the door after a short series of sharp stabs.
Charlie
-
9th November 2018, 19:08 #9
0Re: Multiple functions by a single switch
Press 1
Function 1
Press 2
Function 2
Press 3
Function 3
Press 4
Function 4. and so on..
Press 1
Decimal point
Press 2
Calibration factor
Press 3
Mode
Press 4
Calibration
Press 5
Multiplying factor
End
I will upload a video tomorrowLast edited by amod; 9th November 2018 at 19:13.
-
10th November 2018, 08:38 #10
- Join Date
- Sep 2004
- Posts
- 2,405
- Total Downloaded
- 4.08 GB
Thumbs Up Received: 94
Given: 24
0Re: Multiple functions by a single switch
So my example code works for you. I used that method long time ago and it works, maybe it needs some tweaks but it works. If you have an LCD attached it is even better because you can see at what stage your push sequence have arrived.
Not only it works with a push button. Long time ago I have managed to use a singe R/C channel with a spring loaded switch to activate 3 separate items depends on how many times I toggled the switch.Regards
Joseph
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
This valuable resource relies upon the very
small amount of revenue generated by displaying online advertisements
to our visitors.
The advertisements we display are relevant to this web site and your
browsing history
Please consider supporting us by disabling your ad blocker.
Note: Some users have reported issues related to ad-blockers rendering
parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this
resource with adblocking enabled.
If you can, please report issues in the forum area WebSite / Forum Issues
Thank you for your attention.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
TCK106AF, TCK107AF and TCK108AF single-chip load switch ICs
By normnet in forum New devices and techniquesReplies: 0Last Post: 31st March 2016, 23:19 -
Multiple button on a single ADC port.
By wirecut in forum Proton Plus Compiler v3Replies: 10Last Post: 14th July 2014, 19:52 -
New ADG5419 single-pole/double-throw (SPDT) switch
By normnet in forum New devices and techniquesReplies: 0Last Post: 5th April 2014, 23:09 -
New ADG5419 single-pole/double-throw (SPDT) switch
By normnet in forum The LoungeReplies: 0Last Post: 5th April 2014, 23:09 -
Multiple PIC's driven from a single reset
By knight in forum The LoungeReplies: 8Last Post: 24th October 2010, 08:56
Proton Compiler Updates
Full install of 8-bit Proton and Proton24 Download the full compiler...
1st January 1970, 01:00