The Interfacing of BBB(Beagle Bone Black) with switch and led are shown in figure below. However in this assignment we have interfaced only LED's with BBB(Beagle Bone Black).
The following python code helps to simulate working of signal lights using Beagle Bone Black:
import time
import Adafruit_BBIO.GPIO as a
a.setup("P8_10", a.OUT) #red LED
a.setup("P8_12", a.OUT) #yellow LED
a.setup("P8_14", a.OUT) #green LED
while True:
a.output("P8_10", a.HIGH)
time.sleep(5)
a.output("P8_10", a.LOW)
a.output("P8_12", a.HIGH)
time.sleep(5)
a.output("P8_12", a.LOW)
a.output("P8_14", a.HIGH)
time.sleep(5)
a.output("P8_14", a.LOW)
At some Places all the Traffic Lights start blinking at night time after normal execution throughout the day. This situation can be simulated by the following Python code using Beagle Bone Black:
import time
import Adafruit_BBIO.GPIO as a
a.setup("P8_10", a.OUT) #red LED
a.setup("P8_12", a.OUT) #yellow LED
a.setup("P8_14", a.OUT) #green LED
count=10
count_1=4
while True:
while count>0:
a.output("P8_10", a.HIGH)
time.sleep(2)
a.output("P8_10", a.LOW)
a.output("P8_12", a.HIGH)
time.sleep(2)
a.output("P8_12", a.LOW)
a.output("P8_14", a.HIGH)
time.sleep(2)
a.output("P8_14", a.LOW)
count=count-1
count=10
while count_1>0:
a.output("P8_10", a.HIGH)
a.output("P8_12", a.HIGH)
a.output("P8_14", a.HIGH)
time.sleep(1)
a.output("P8_10", a.LOW)
a.output("P8_12", a.LOW)
a.output("P8_14", a.LOW)
time.sleep(2)
count_1=count_1-1
count_1=4
No comments:
Post a Comment