I've used this "instructable" method to run my script on boot which works fine, but I have no way to end the program while the Pi is running. I but to the GUI in Raspbian.
I tried the pygame module as described but nothing happens.
I think a shell should appear in which I can see the executed program and ctrl+c to end if desired.
i have no end condition. perhaps someone may suggest a method? the script is:
import RPi.GPIO as IO
import time
import random
IO.setwarnings(False)
IO.setmode(IO.BCM)
IO.setup(26, IO.OUT)
IO.setup(16, IO.OUT)
IO.setup(13, IO.OUT)
IO.setup(27, IO.OUT)
IO.setup(18, IO.OUT)
IO.setup(17, IO.OUT)
IO.setup(4, IO.IN)
def pattern1():
(IO.output(26, True), IO.output(16, True), IO.output(27, True), IO.output(18, True), IO.output(13, False), IO.output(17, False), time.sleep(0.75), IO.output(16, True), IO.output(13, True), IO.output(18, True), IO.output(17, True), IO.output(26, False), IO.output(27, False), time.sleep(0.75), IO.output(13, True), IO.output(27, True), IO.output(17, True), IO.output(26, True), IO.output(16, False), IO.output(18, False), time.sleep(0.75))
def pattern2():
(IO.output(26, True), IO.output(16, True), IO.output(27, True), IO.output(18, True), IO.output(13, True), IO.output(17, True), time.sleep(0.5))
def pattern_off():
(IO.output(26, False), IO.output(16, False), IO.output(13, False), IO.output(27, False), IO.output(18, False), IO.output(17, False))
def pattern_flasher_x_3():
(pattern_off(), time.sleep(0.5), pattern2(), time.sleep(0.5), pattern_off(), time.sleep(0.5), pattern2(), time.sleep(0.5), pattern_off(), time.sleep(0.5), pattern2(), time.sleep(0.5))
try:
while True:
if IO.input(4)==1:
for i in range(50):
pattern1()
for i in range(1):
pattern_flasher_x_3()
else:
pattern_off()
while False:
pattern_off()
finally:
IO.cleanup()
i did some looking around and found that having an auxiliary input to trigger a "quit" works. in the while True and while False parts i added:
if IO.input(25) == True:
quit()