tact switch
johnproko
Posts: 121
hello all.
i have a question regarding the tact switch.
i have plenty of those because every time i bought something they gave them.
i want to build a robotic arm that is controlled by these switches.
when i attach them to a simple circuit (battery- tact- led) they work just fine.
when i do the exactly same thing to the breadboard nothing happens... :-(
the code i use is
do
if in5= 1 then
debug "yes"
endif
loop
doesn't seem to work and i get all the time yes until it crashes.
its a four leg tact switch.
until now I'm using a force button but I'm limited to one and it doesn't always get the push
thank you in advance!
i have a question regarding the tact switch.
i have plenty of those because every time i bought something they gave them.
i want to build a robotic arm that is controlled by these switches.
when i attach them to a simple circuit (battery- tact- led) they work just fine.
when i do the exactly same thing to the breadboard nothing happens... :-(
the code i use is
do
if in5= 1 then
debug "yes"
endif
loop
doesn't seem to work and i get all the time yes until it crashes.
its a four leg tact switch.
until now I'm using a force button but I'm limited to one and it doesn't always get the push
thank you in advance!
Comments
+V to switch_1a, switch_1b to input pin? [That won't work.]
It's one of the 4-legged jobs, you need to know which are the contacts.
(People get those turned around all the time.)
'
[ Title ]
' {$STAMP BS2} ' Stamp directive.
' {$PBASIC 2.5} ' PBASIC directive.
switch1 VAR Bit
switch1 = 0
DEBUG "Testing ..."
DO
switch1 = IN5
IF switch1 = 1 THEN
DEBUG HOME, CR, " pressed...", CLREOL
ELSE
DEBUG HOME, CR, " not pressed this time", clreol
ENDIF
LOOP
Check all your wiring as PJ sugests. Try this code and let us know how it goes.
Also, the program is written for an Active-High (Active state is 1) pushbutton so there needs to be a Pull-down resistor (connected to ground) for reliable operation.
Look at the circuits and code in What's a Microcontroller and other Stamps-In-Class texts.
P5 <--- PB ---> Vdd = 5V
|_<--- 10K ---> Vss = Ground