Controlling Lights with electrical circuits
In the following sections, you will find ideas on how to dive into more projects that control other devices in the house.
Electrical appliances
In houses we have electrical appliances, for example, lamps, washing machines, heaters, and other appliances that we only need to turn on or off. In this section, we will learn how to control a lamp connected to the Raspberry Pi Zero, using electrical circuits for interfacing the signal. We will use an optocoupler such as MOC3011, and a Triac. The following figure shows the circuit of the application:
Here we have the final project connected to the Raspberry pi Zero:
Here we have the JavaScript code for controlling the device:
// Modules var express = require('express'); // Express app var app = express(); // Pin var lampPin = 12; // Use public directory app.use(express.static('public')); // Routes app.get('/', function (req, res...