Last active
August 29, 2015 14:18
-
-
Save kcranley1/e475a38755e536bda8ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GPIO GUI by S&S 5-Apr-15 | |
from Tkinter import * | |
import RPi.GPIO as GPIO | |
import time | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BCM) | |
def turn1on(): | |
GPIO.setup(18, GPIO.OUT) | |
GPIO.output(18, GPIO.LOW) | |
GPIO.setup(23, GPIO.OUT) | |
GPIO.output(23, GPIO.HIGH) | |
GPIO.setup(24, GPIO.IN) | |
GPIO.input(24) | |
GPIO.setup(25, GPIO.IN) | |
GPIO.input(25) | |
def turn2on(): | |
GPIO.setup(18, GPIO.OUT) | |
GPIO.output(18, GPIO.HIGH) | |
GPIO.setup(23, GPIO.OUT) | |
GPIO.output(23, GPIO.LOW) | |
GPIO.setup(24, GPIO.IN) | |
GPIO.input(24) | |
GPIO.setup(25, GPIO.IN) | |
GPIO.input(25) | |
def turn3on(): | |
GPIO.setup(18, GPIO.IN) | |
GPIO.input(18) | |
GPIO.setup(23, GPIO.OUT) | |
GPIO.output(23, GPIO.LOW) | |
GPIO.setup(24, GPIO.OUT) | |
GPIO.output(24, GPIO.HIGH) | |
GPIO.setup(25, GPIO.IN) | |
GPIO.input(25) | |
def turn4on(): | |
GPIO.setup(18, GPIO.IN) | |
GPIO.input(18) | |
GPIO.setup(23, GPIO.OUT) | |
GPIO.output(23, GPIO.HIGH) | |
GPIO.setup(24, GPIO.OUT) | |
GPIO.output(24, GPIO.LOW) | |
GPIO.setup(25, GPIO.IN) | |
GPIO.input(25) | |
def turn5on(): | |
GPIO.setup(18, GPIO.IN) | |
GPIO.input(18) | |
GPIO.setup(23, GPIO.IN) | |
GPIO.input(23) | |
GPIO.setup(24, GPIO.OUT) | |
GPIO.output(24, GPIO.LOW) | |
GPIO.setup(25, GPIO.OUT) | |
GPIO.output(25, GPIO.HIGH) | |
def turn6on(): | |
GPIO.setup(18, GPIO.IN) | |
GPIO.input(18) | |
GPIO.setup(23, GPIO.IN) | |
GPIO.input(23) | |
GPIO.setup(24, GPIO.OUT) | |
GPIO.output(24, GPIO.HIGH) | |
GPIO.setup(25, GPIO.OUT) | |
GPIO.output(25, GPIO.LOW) | |
def turn7on(): | |
GPIO.setup(18, GPIO.OUT) | |
GPIO.output(18, GPIO.LOW) | |
GPIO.setup(23, GPIO.IN) | |
GPIO.input(23) | |
GPIO.setup(24, GPIO.OUT) | |
GPIO.output(24, GPIO.HIGH) | |
GPIO.setup(25, GPIO.IN) | |
GPIO.input(25) | |
def turn8on(): | |
GPIO.setup(18, GPIO.OUT) | |
GPIO.output(18, GPIO.HIGH) | |
GPIO.setup(23, GPIO.IN) | |
GPIO.input(23) | |
GPIO.setup(24, GPIO.OUT) | |
GPIO.output(24, GPIO.LOW) | |
GPIO.setup(25, GPIO.IN) | |
GPIO.input(25) | |
def turn9on(): | |
GPIO.setup(18, GPIO.IN) | |
GPIO.input(18) | |
GPIO.setup(23, GPIO.OUT) | |
GPIO.output(23, GPIO.LOW) | |
GPIO.setup(24, GPIO.IN) | |
GPIO.input(24) | |
GPIO.setup(25, GPIO.OUT) | |
GPIO.output(25, GPIO.HIGH) | |
def turn10on(): | |
GPIO.setup(18, GPIO.IN) | |
GPIO.input(18) | |
GPIO.setup(23, GPIO.OUT) | |
GPIO.output(23, GPIO.HIGH) | |
GPIO.setup(24, GPIO.IN) | |
GPIO.input(24) | |
GPIO.setup(25, GPIO.OUT) | |
GPIO.output(25, GPIO.LOW) | |
def turn11on(): | |
GPIO.setup(18, GPIO.OUT) | |
GPIO.output(18, GPIO.LOW) | |
GPIO.setup(23, GPIO.IN) | |
GPIO.input(23) | |
GPIO.setup(24, GPIO.IN) | |
GPIO.input(24) | |
GPIO.setup(25, GPIO.OUT) | |
GPIO.output(25, GPIO.HIGH) | |
def turn12on(): | |
GPIO.setup(18, GPIO.OUT) | |
GPIO.output(18, GPIO.HIGH) | |
GPIO.setup(23, GPIO.IN) | |
GPIO.input(23) | |
GPIO.setup(24, GPIO.IN) | |
GPIO.input(24) | |
GPIO.setup(25, GPIO.OUT) | |
GPIO.output(25, GPIO.LOW) | |
def toggle1(): | |
greyall() | |
turn1on() | |
toggleButton1["background"] = "red" | |
def toggle2(): | |
greyall() | |
turn2on() | |
toggleButton2["background"] = "red" | |
def toggle3(): | |
greyall() | |
turn3on() | |
toggleButton3["background"] = "red" | |
def toggle4(): | |
greyall() | |
turn4on() | |
toggleButton4["background"] = "red" | |
def toggle5(): | |
greyall() | |
turn5on() | |
toggleButton5["background"] = "red" | |
def toggle6(): | |
greyall() | |
turn6on() | |
toggleButton6["background"] = "red" | |
def toggle7(): | |
greyall() | |
turn7on() | |
toggleButton7["background"] = "red" | |
def toggle8(): | |
greyall() | |
turn8on() | |
toggleButton8["background"] = "red" | |
def toggle9(): | |
greyall() | |
turn9on() | |
toggleButton9["background"] = "red" | |
def toggle10(): | |
greyall() | |
turn10on() | |
toggleButton10["background"] = "red" | |
def toggle11(): | |
greyall() | |
turn11on() | |
toggleButton11["background"] = "red" | |
def toggle12(): | |
greyall() | |
turn12on() | |
toggleButton12["background"] = "red" | |
def greyall(): | |
toggleButton1["background"] = "grey" | |
toggleButton2["background"] = "grey" | |
toggleButton3["background"] = "grey" | |
toggleButton4["background"] = "grey" | |
toggleButton5["background"] = "grey" | |
toggleButton6["background"] = "grey" | |
toggleButton7["background"] = "grey" | |
toggleButton8["background"] = "grey" | |
toggleButton9["background"] = "grey" | |
toggleButton10["background"] = "grey" | |
toggleButton11["background"] = "grey" | |
toggleButton12["background"] = "grey" | |
def turnalloff(): | |
# greyall() | |
GPIO.setup(18, GPIO.OUT) | |
GPIO.output(18, GPIO.LOW) | |
GPIO.setup(23, GPIO.OUT) | |
GPIO.output(23, GPIO.LOW) | |
GPIO.setup(24, GPIO.OUT) | |
GPIO.output(24, GPIO.LOW) | |
GPIO.setup(25, GPIO.OUT) | |
GPIO.output(25, GPIO.LOW) | |
GPIO.setup(18, GPIO.IN) | |
GPIO.input(18) | |
GPIO.setup(23, GPIO.IN) | |
GPIO.input(23) | |
GPIO.setup(24, GPIO.IN) | |
GPIO.input(24) | |
GPIO.setup(25, GPIO.IN) | |
GPIO.input(25) | |
def turnallon0(): | |
delay = 0.0 | |
for x in range(0,500): | |
toggle1() | |
time.sleep(delay) | |
turnalloff() | |
toggle3() | |
time.sleep(delay) | |
turnalloff() | |
toggle5() | |
time.sleep(delay) | |
turnalloff() | |
toggle6() | |
time.sleep(delay) | |
turnalloff() | |
toggle11() | |
time.sleep(delay) | |
turnalloff() | |
toggle12() | |
time.sleep(delay) | |
turnalloff() | |
toggle10() | |
time.sleep(delay) | |
turnalloff() | |
toggle8() | |
time.sleep(delay) | |
turnalloff() | |
toggle7() | |
time.sleep(delay) | |
turnalloff() | |
toggle2() | |
time.sleep(delay) | |
turnalloff() | |
toggle4() | |
time.sleep(delay) | |
turnalloff() | |
toggle9() | |
time.sleep(delay) | |
turnalloff() | |
toggle10() | |
time.sleep(delay) | |
turnalloff() | |
toggle8() | |
time.sleep(delay) | |
turnalloff() | |
toggle7() | |
time.sleep(delay) | |
turnalloff() | |
toggle2() | |
time.sleep(delay) | |
turnalloff() | |
greyall() | |
def turnallon1(): | |
delay = 0.1 | |
for x in range(0,10): | |
toggle1() | |
time.sleep(delay) | |
turnalloff() | |
toggle3() | |
time.sleep(delay) | |
turnalloff() | |
toggle5() | |
time.sleep(delay) | |
turnalloff() | |
toggle6() | |
time.sleep(delay) | |
turnalloff() | |
toggle11() | |
time.sleep(delay) | |
turnalloff() | |
toggle12() | |
time.sleep(delay) | |
turnalloff() | |
toggle10() | |
time.sleep(delay) | |
turnalloff() | |
toggle8() | |
time.sleep(delay) | |
turnalloff() | |
toggle2() | |
time.sleep(delay) | |
turnalloff() | |
toggle4() | |
time.sleep(delay) | |
turnalloff() | |
toggle9() | |
time.sleep(delay) | |
turnalloff() | |
toggle10() | |
time.sleep(delay) | |
turnalloff() | |
toggle8() | |
time.sleep(delay) | |
turnalloff() | |
toggle7() | |
time.sleep(delay) | |
turnalloff() | |
toggle9() | |
time.sleep(delay) | |
turnalloff() | |
toggle10() | |
time.sleep(delay) | |
turnalloff() | |
toggle8() | |
time.sleep(delay) | |
turnalloff() | |
toggle7() | |
time.sleep(delay) | |
turnalloff() | |
toggle2() | |
time.sleep(delay) | |
turnalloff() | |
greyall() | |
root = Tk() | |
root.title("Charlie") | |
turnalloff() | |
quitButton = Button(root, text="Quit", command=exit) | |
quitButton.grid(row=0, columnspan=5) | |
clearAllButton = Button(root, text="Clear", command=turnalloff) | |
clearAllButton.grid(row=1, columnspan=5) | |
loopAllButton0 = Button(root, text="Loop - no delay", command=turnallon0) | |
loopAllButton0.grid(row=2, columnspan=5) | |
loopAllButton1 = Button(root, text="Loop - 0.1s delay", command=turnallon1) | |
loopAllButton1.grid(row=3, columnspan=5) | |
toggleButton1 = Button(root, text=" 1", command=toggle1, foreground="white", background="grey") | |
toggleButton1.grid(row=4, column=1) | |
toggleButton2 = Button(root, text=" 2", command=toggle2, foreground="white", background="grey") | |
toggleButton2.grid(row=4, column=2) | |
toggleButton3 = Button(root, text=" 3", command=toggle3, foreground="white", background="grey") | |
toggleButton3.grid(row=5, column=1) | |
toggleButton4 = Button(root, text=" 4", command=toggle4, foreground="white", background="grey") | |
toggleButton4.grid(row=5, column=2) | |
toggleButton5 = Button(root, text=" 5", command=toggle5, foreground="white", background="grey") | |
toggleButton5.grid(row=6, column=1) | |
toggleButton6 = Button(root, text=" 6", command=toggle6, foreground="white", background="grey") | |
toggleButton6.grid(row=6, column=2) | |
toggleButton7 = Button(root, text=" 7", command=toggle7, foreground="white", background="grey") | |
toggleButton7.grid(row=4, column=3) | |
toggleButton8 = Button(root, text=" 8", command=toggle8, foreground="white", background="grey") | |
toggleButton8.grid(row=4, column=4) | |
toggleButton9 = Button(root, text=" 9", command=toggle9, foreground="white", background="grey") | |
toggleButton9.grid(row=5, column=3) | |
toggleButton10 = Button(root, text="10", command=toggle10, foreground="white", background="grey") | |
toggleButton10.grid(row=5, column=4) | |
toggleButton11 = Button(root, text="11", command=toggle11, foreground="white", background="grey") | |
toggleButton11.grid(row=6, column=3) | |
toggleButton12 = Button(root, text="12", command=toggle12, foreground="white", background="grey") | |
toggleButton12.grid(row=6, column=4) | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment