In this section, we will learn to interface one decorative appliance and a speaker. We will create a form and buttons on an HTML page to control the devices.
In this task, we will review the code (available along with this chapter) required to interface decorative appliances and lighting arranging to a web page and controlled over a local network. Let's get started with opening the file using a text editing tool (Python IDLE's text editor or any other text editor).
We will import the following modules to get started with the program:
import web from web import form import RPi.GPIO as GPIO import os
The GPIO module is initialized, the board numbering is set, and ensure that all appliances are turned off by setting the GPIO pins to low or
false
and declare any global variables:#Set board GPIO.setmode(GPIO.BCM) #Initialize the pins that have to be controlled GPIO.setup(25,GPIO.OUT) GPIO.output(25,False)
This is followed by defining the...