7 years ago
I was very pleasantly surprised to be find out about this newsgroup.
It would be appreciated if anyone here could help me with my GPIO
I am building a device that has three arcade buttons ("Massive Arcade
Buttons" from Adafruit) attached to a Raspberry Pi via the GPIO pins. The
Pi is attached to a Blinkstick Pro that controls an analog LED light
strip. The idea is that pushing a button will change the LED strip to the
colour of that button and the Pi will record how much time the strip
spends as each colour.
For quick develop purposes I replaced the code that changes the colour
of the LED strip with a print statment. Once I have the buttons working I
will go back to the colour changing code.
It does not work right now. All my variations of the code result in one
of three problems. An error message stating "Conflicting edge detection
already enabled for this GPIO channel", the script running then quiting
in under one second, or sitting there being unresponsive to anything.
Here is the script. This very is unresponsive, unless I remove the sleep
command. When I do that it runs and quits instantly.
from blinkstick import blinkstick
import RPi.GPIO as GPIO
led = blinkstick.find_first()
colour = 0
timered = 0
timeyellow = 0
timeblue = 0
timestamp = time.strftime("%H:%M:%S")
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
colour = 1
while colour == 1:
print "Red Button pressed"
timered += 1
colour = 2
while colour == 2:
print "Yellow Button pressed"
timeyellow += 1
colour = 3
while colour == 3:
print "Blue Button pressed"
timeblue += 1
GPIO.add_event_detect(23, GPIO.RISING, callback=yellow_button,
GPIO.add_event_detect(22, GPIO.RISING, callback=red_button,
GPIO.add_event_detect(24, GPIO.RISING, callback=blue_button,
print '\033[0;41;37mRed Team:\033[0m ', timered
print '\033[0;103;30mYellow Team:\033[0m ', timeyellow
print '\033[0;44;37mBlue Team:\033[0m ', timeblue
flog = open('flag1log.text', 'a')
flog.write(timestamp + '\n' + 'Red Team: ' + str(timered) + '\n' +
'Yellow Team: ' + str(timeyellow) + '\n' + 'Blue Team: ' + str(timeblue)
Would very much appreciate help getting this working. Thank you.