-
Notifications
You must be signed in to change notification settings - Fork 0
/
4_input.py
executable file
·57 lines (45 loc) · 1.08 KB
/
4_input.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
#This program adds a blinking LED
import os
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
#Setup variables for user input
led_choice = 0
count = 0
os.system('clear')
print "Witch LED would you like to blink"
print "1: Red"
print "2: Blue"
led_choice = input("Choose your option: ")
if led_choice == 1:
os.system('clear')
print "You picked the Red LED"
count = input("How many times would you like it to blink?: ")
while count > 0:
GPIO.output(27, GPIO.HIGH)
time.sleep(1)
GPIO.output(27, GPIO.LOW)
time.sleep(1)
count = count -1
if led_choice == 2:
os.system('clear')
print "You picked the Blue LED"
count = input("How many times would you like it to blink?: ")
while count > 0:
GPIO.output(17, GPIO.HIGH)
time.sleep(1)
GPIO.output(17, GPIO.LOW)
time.sleep(1)
count = count -1
#print "Lights on"
#GPIO.output (17, GPIO.HIGH)
#GPIO.output (27, GPIO.HIGH)
#time.sleep(1)
#print "Lights off"
#GPIO.output (17, GPIO.LOW)
#GPIO.output (27, GPIO.LOW)
GPIO.cleanup()