Question: Solution - python code - import RPi.GPIO as GPIO from flask import Flask, render _ template , request app = Flask ( _ name _

Solution -
python code -
import RPi.GPIO as GPIO
from flask import Flask, render_template , request
app = Flask(_name_)
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
ledRed=13
ledYellow=19
ledGreen=26
ledRedSts=0
ledYellowSts=0
ledGreenSts=0
GPIO.setup(ledRed, GPIO.OUT)
GPIO.setup(ledYellow, GPIO.OUT)
GPIO.setup(ledGreen, GPIO.OUT)
GPIO.uotput(ledRed, GPIO.LOW)
GPIO.uotput(ledYellow, GPIO.LOW)
GPIO.uotput(ledGreen, GPIO.LOW)
@app.route('/')
def index():
ledRedSts = GPIO.input(ledRed)
ledYellowSts = GPIO.input(ledYellow)
ledGreenSts = GPIO.input(ledgreen)
templateData ={'ledRed' :ledRedSts ,
ledYellow' :ledYellowSts,
ledGreen' :ledGreenSts}
return render_template('index.html',**templateData)
@app.route('//')
def do(deviceName , action):
if deviceName =="ledRed":
actuator==ledRed
if deviceName =="ledYellow":
actuator==ledYellow
if deviceName =="ledGreen":
actuator==ledGreen
if action =="on":
GPIO.output(actuator,GPIO.HIGH)
if action =="off":
GPIO.output(actuator,GPIO.LOW)
ledRedSts=GPIO.input(ledRed)
ledYellowSts=GPIO.input(ledYellow)
ledGreen=GPIO.input(ledGreen)
templateData ={'ledRed' :ledRedSts ,
ledYellow' :ledYellowSts,
ledGreen' :ledGreenSts}
return render_template('index.html',**templateData)
if _name_=="_main_":
app.run(host ='0.0.0.0',debug=True)
Html code-
GPIO Control Web App
a simple home automation system protoype is to be designed using raspberry pi, it should satisfy the following features:
the system is to be turned on and off using external switch
outdoor lights are to be turned on and off according to ambient light conditions.
the system includes motion sensor (PIR sensor )placed at the main gate of the house,whenever motion is detected ,an led is to be turned on a buzzer is start beeping with a frequency 1 hz and raspberry pi camera is to take still image and save it.
after taking the still image , the system should wait for a response from owner ,if the owner presses corresponding pushbutton , servomotor should rotate in order to open the gate (going from angle 0 to 180)
when the gate is open ,an ultrasonic sensor should detect an in-range movement , when no movement is in-range after 10 seconds , the gate will close .
a)draw a flowchart of the described system.
b)draw the schematic of all connections needed for the described system .
c)write the python code needed for all features of the described system , your code should satisfy the flowchart uploaded in part a.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!