官术网_书友最值得收藏!

The applications of GPIO control

Now that we have implemented our first example, let's discuss some possible applications of being able to control the GPIO. We could use the Raspberry Pi's GPIO to control the lights in our homes. We will make use of the same example to control a table lamp!

There is a product called the PowerSwitch Tail II (http://www.powerswitchtail.com/Pages/default.aspx) that enables interfacing AC appliances like a table lamp to a Raspberry Pi. The PowerSwitch Tail comes with control pins (that can take a 3.3V high signal) that could be used to turn on/off a lamp. The switch comes with the requisite circuitry/protection to interface it directly to a Raspberry Pi Zero:

The Pi Zero interfaced to the PowerSwitch Tail II

Let's take the same example from the previous section and connect the GPIO pin 2 to the +in pin of the PowerSwitch Tail. Let's connect the ground pin of the Raspberry Pi Zero's GPIO header to the PowerSwitch Tail's -in pain. The PowerSwitch Tail should be connected to the AC mains. The lamp should be connected to the AC output of the switch. If we use the same piece of code and connect a lamp to the PowerSwitch Tail, we should be able to turn on/off with a 1-second interval.

PowerSwitch Tail II connected to a Raspberry Pi Zero

This appliance control using the LED blinking code is just an example. It is not recommended to turn on/off a table lamp at such short intervals. In future chapters, we will make use of the Raspberry Pi Zero's GPIO to control appliances from anywhere on the Internet.

主站蜘蛛池模板: 金堂县| 丹寨县| 南澳县| 弋阳县| 靖远县| 洞口县| 莫力| 南陵县| 大理市| 新乡市| 合川市| 绥阳县| 云龙县| 富顺县| 永州市| 邹城市| 上思县| 白水县| 南华县| 耒阳市| 寿宁县| 泗水县| 抚宁县| 钦州市| 石林| 咸丰县| 汕头市| 扎赉特旗| 平舆县| 佛学| 桂平市| 正蓝旗| 青神县| 龙泉市| 合作市| 赣榆县| 山阳县| 临泉县| 景泰县| 鸡泽县| 赤峰市|