forked from Sonukumar50846/IOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
button_operate.py
42 lines (38 loc) · 922 Bytes
/
button_operate.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
# imported time
import time
# imported GPIO
import RPi.GPIO as gpio
# setting mode of RPi
gpio.setmode(gpio.BCM)
# initializing
button=2
led1=3
led2=4
led3=27
led4=17
# loop
for i in range(4):
# switching on led1 and off others
gpio.setup(led1,gpio.HIGH)
gpio.setup(led2,gpio.LOW)
gpio.setup(led3,gpio.LOW)
gpio.setup(led4,gpio.LOW)
time.sleep(1)
# switching on led1 and off others
gpio.setup(led2,gpio.HIGH)
gpio.setup(led1,gpio.LOW)
gpio.setup(led3,gpio.LOW)
gpio.setup(led4,gpio.LOW)
time.sleep(1)
# switching on led1 and off others
gpio.setup(led3,gpio.HIGH)
gpio.setup(led2,gpio.LOW)
gpio.setup(led1,gpio.LOW)
gpio.setup(led4,gpio.LOW)
time.sleep(1)
# switching on led1 and off others
gpio.setup(led4,gpio.HIGH)
gpio.setup(led2,gpio.LOW)
gpio.setup(led3,gpio.LOW)
gpio.setup(led1,gpio.LOW)
time.sleep(1)