Hi everyone,
I am a bit new to this, but had a quick question. I am building a retropie setup with the blinkt. I have a push button that turns it on, the blinkt comes on perfectly fine, just when shuts down the blinkt is still on as well. Anyone know what i can add to the rainbow.py code to get it to shutoff as well
rainbow.py code
#!/usr/bin/env python
import colorsys
import time
from blinkt import set_clear_on_exit, set_brightness, set_pixel, show
spacing = 360.0 / 16.0
hue = 0
set_clear_on_exit()
set_brightness(0.1)
while True:
hue = int(time.time() * 100) % 360
for x in range(8):
offset = x * spacing
h = ((hue + offset) % 360) / 360.0
r, g, b = [int(c*255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
set_pixel(x,r,g,b)
show()
time.sleep(0.001)
my shutoff code
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BOARD)
GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP)
oldButtonState1 = True
while True:
#grab the current button state
buttonState1 = GPIO.input(5)
# check to see if button has been pushed
if buttonState1 != oldButtonState1 and buttonState1 == False:
subprocess.call("shutdown -h now", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
oldButtonState1 = buttonState1
time.sleep(.1)