Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 22nd International Conference Dexa 2011 Toulouse France August/September 2011 Proceedings Part 1 Lncs 6860

Authors: Abdelkader Hameurlain ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2011th Edition

3642230873, 978-3642230875

More Books

Students also viewed these Databases questions

Question

Explain and give an example of the false consensus effect.

Answered: 1 week ago