Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 22.4 ('Spy On Your Variables')
Instant purchase and download via GumRoad!

FEATURE

A Household Light Controller

Raspberry Pi Part 8

Issue: 22.4 (July/August 2024)
Author: Eugene Dakin
Author Bio: Eugene works as a Senior Oilfield Technical Specialist. He holds university degrees in the disciplines of Engineering, Chemistry, Biology, Business, and a Ph.D. in Chemical Engineering. He is the author of dozens of books on Xojo available on the xdevlibrary.com website.
Article Description: No description available.
Article Length (in bytes): 11,150
Starting Page Number: 20
Article Number: 22403
Resource File(s):

Download Icon project22403.zip Updated: 2024-07-01 10:15:25

Related Web Link(s):

http://abyz.me.uk/lg/lg.zip

Excerpt of article text...

This article demonstrates how to control a 120-volt light by switching a relay with the Raspberry Pi 5 or Raspberry Pi 4. A word of caution: Since this project can work with household voltage of 120 or 240 volts, please be careful, as household electricity can be dangerous. Please ensure that you know what you are doing.

Warning: I would suggest that the person constructing this project should use an ohm-meter instead of house current to prove that the circuits work fully before using large wattage appliances.

It is exhilarating to be able to program a Raspberry Pi that takes the programming code and can control the real world, such as light bulbs, garage door openers, and other items around the house. This project includes parts that protect the Raspberry Pi GPIO pins while allowing control of a large power source from your house to power a light bulb.

This example works with a Raspberry Pi 4 or the newest Raspberry Pi 5. To make the example work on the Raspberry Pi 5, change the opening line of code from lgGpiochipOpen(0) to lgGpiochipOpen(4), where 4 is the latest chipset. A strong suggestion is to not use the 120-volt power supply. An Ohm-Meter can be used instead of the alternating current power supply to ensure that the relay is switching properly. This example uses the Raspberry Pi OS in 64-bit mode.

...End of Excerpt. Please purchase the magazine to read the full article.