I want to make a on/off signal with only a push button, actually its for my WiiMote but I don't think that that makes a difference. I want a led to turn it on and off.
I was thinking about a counter in Python, state 1 is signal ON and state 2 is reset to 0 (0 would be OFF). I have seen other posts about this and tried them, but none of them work:(
This is what I tried.
while True: if (GPIO.input(11) == 1): if (status == 0): GPIO.output(22, 0) status = 1 if (status == 1): GPIO.output(22, 1) status = 0
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(22, GPIO.OUT) # LED GPIO.setup(11, GPIO.IN) # Button def toggleLEDcallback(channel): if (GPIO.input(22) == True): GPIO.output(22, False) else: GPIO.output(22, True) while True: ... # do some other stuff ... GPIO.cleanup()
I tried also with 2 transistors but that didn't work either. Any other hardware Solutions?
I hope one of you would like to help me building my robot!!
Below I paste a photo of my robot, for in case you where wondering how it looks like;)