Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

A basic projects needs to have 3 LEDs on the breadboard, which need to work as follows: • When the distance measured is greater than 20 cm, light the Green LED • When the distance is between 5 cm and...

1 answer below »
A basic projects needs to have 3 LEDs on the breadboard, which need to work as follows: • When the distance measured is greater than 20 cm, light the Green LED • When the distance is between 5 cm and 20 cm, light the Yellow LED • When the distance is 5 cm or less, light the Red LED • Only one LED is on at any given time The breadboard also needs a buzzer connected, which needs to operate as follows: • Off for distance above 20 cm • Beep for distance between 5 cm and 20 cm • Constant on for distance 5 cm and belowYou will need to use multiple nested if statements, but you should not resort to compound logical statements (and/or keywords). Consider the following pseudo-code: read_sensor function (run as a thread): while sensor is active: read distance if distance is long: activate green LED, deactivate yellow and red LEDs turn off buzzer else distance is medium: activate yellow LED, deactivate green and red LEDs beep buzzer if buzzer is allowed else: activate red LED, deactivate green and yellow LEDs turn on buzzer if buzzer is allowed wait a moment 8. Avoid using the sleep statement. It should only be used once in your entire program, to slow down the main program loop.


Answered Same Day Apr 05, 2021

Solution

Vicky answered on Apr 06 2021
146 Votes
#!/us
in/python3
"""Carlos He
era"""
from signal import signal, SIGTERM, pause, SIGHUP
from time import sleep
from threading import Thread
#import gpiozero
from gpiozero import DistanceSensor, Buzzer, LEDBoard, Button, LED
#from gpiozero.pins.mock import MockFactory
#gpiozero.Device.pin_factory = MockFactory()
#import RPi.GPIO as GPIO
eading = True
distance = True
uzzer = True
#GPIO.setmode(GPIO.BOARD) # choose BCM or BOARD
#GPIO.setup(24, GPIO.OUT)
sensor =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here