Get button form 74hc165
Sabai
Posts: 27
I am using a shift register and I have problem to with the code determine what button is pressed. It all work and I can see in the debug window that the button is pressed. I am using the example code 24.
My goal will be to do like this
If switches.bit0 = 1 then
Gosub button1
Endif
If switches.bit1 = 1 then
Gosub button2
Endif
If switches.bit2 = 1 then
Gosub button3
Endif
And so on for all 8 buttons.
I have tried this code:
Get_165:
PULSOUT Load, 5 ' load switch inputs
SHIFTIN SerData, Clock, MSBPRE, [noparse][[/noparse]switches]
IF switches.BIT0 = 1 THEN
GOTO test
ENDIF ' shift them in
RETURN
But I can not get it to work
B
My goal will be to do like this
If switches.bit0 = 1 then
Gosub button1
Endif
If switches.bit1 = 1 then
Gosub button2
Endif
If switches.bit2 = 1 then
Gosub button3
Endif
And so on for all 8 buttons.
I have tried this code:
Get_165:
PULSOUT Load, 5 ' load switch inputs
SHIFTIN SerData, Clock, MSBPRE, [noparse][[/noparse]switches]
IF switches.BIT0 = 1 THEN
GOTO test
ENDIF ' shift them in
RETURN
But I can not get it to work
B
Comments
Somewhere in your code there's "GOSUB Get_165" (probably in the Main procedure).
Right below it, put your "IF .. THEN Button" statements.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
and
and tell us what you get when you press the button.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
B