Winch
Member
Hello a question,
I want to connect five push buttons to one analog input.
I was previously convinced that the code below should suffice for this problem.
But somehow he doesn't want to use the < , > code properly?
In the manual states that this should work with the CASe function.
I see the value of the analog input vary nicely but the number of the relevant switch remains and does not respond.
When I compile I don't get any errors so it seems to work fine.
Does anyone have a tip or idea?
I want to connect five push buttons to one analog input.
I was previously convinced that the code below should suffice for this problem.
But somehow he doesn't want to use the < , > code properly?
In the manual states that this should work with the CASe function.
I use a display where I can read the results neatly. But I don't see any response in the result when pressing the switch.Six standard comparison operators are available: =, <>, >, >=, <, <=. Multiple comma separated conditions can be used with CASE statements, also.
I see the value of the analog input vary nicely but the number of the relevant switch remains and does not respond.
When I compile I don't get any errors so it seems to work fine.
Does anyone have a tip or idea?
Code:
Buttons:
Adcin 0, Switch
Select Case Switch
Case < 1023, > 1015 'Analog value = 1023
Button = 1 'System is in idle mode
Case < 729, > 709 'Analog value = 719
Button = 2 'Switch Select
Case < 482, > 462 'Analog value = 472
Button = 3 'Switch Left
Case < 304, > 284 'Analog value = 294
Button = 4 'Switch Down
Case < 142, > 122 'Analog value = 132
Button = 5 'Switch Up
Case 0 'Analog value = 0
Button = 6 'Switch Right
EndSelect
'=======01234567890123456789=======
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout #Button
Lcdcmdout LcdLine2Home
Lcdout #Switch
WaitMs 200
Return