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 21.4 ('ChatGPT')
Instant purchase and download via GumRoad!

FEATURE

Rasp Pi Electronic Fun Part 2

Using LibGPIOD Interface for Raspberry Pi Electronics

Issue: 21.4 (July/August 2023)
Author: Eugene Dakin
Author Bio: Eugene works as a Senior Oilfield Technical Specialist. He has 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): 8,524
Starting Page Number: 36
Article Number: 21404
Resource File(s):

Download Icon project21404.zip Updated: 2023-07-03 09:54:42

Related Link(s): None

Excerpt of article text...

This example uses a physical switch to change the status of a Textfield on a Window in Xojo. Make sure that LibGpiod module has been installed/added before building this program. Xojo code is provided in the file LibGPIODInput.xojo_binary_project.

The Raspberry Pi 4 B has pins that can provide energy (Output) or read digital signals (Input). A voltage of 3.3 Volts is a logical one, while a voltage of 0.0 Volts is a logical zero. If there are situations where the pins are connected to out-of-range voltages, then external resistors and electronics are used to keep the input range of voltages between 0.0 and 3.3 volts. Common recommendations are to not source more than 0.5 mA in an input pin on the Raspberry Pi. Do not have a capacitive load to an input pin, as it is highly likely to damage the Raspberry Pi chip.

A timer is used for this example to check for the incoming voltage on the breadboard and the threshold voltage is about 1.8 volts, and this number can change. This means that voltages above 1.8 are considered on, and voltage readings below 1.8 volts are considered off. When the button on the breadboard is in the up position and more than half-a-second has passed, then the Textfield has red text with the words Button Up. When the breadboard button is held down and the update button is pressed after more than half-a-second then the Textfield background changes to a green color and the text Button Down is shown (see Figure 1).

To build this program, start Xojo and select a desktop program. Go to the Contents section of the Xojo IDE and add the GPIO module. The latest version of the GPIO module is included in the sample programs which are in the folder: Example Projects -> Platform-Specific -> RaspberryPi.

Select Linux in Build Settings of the IDE, and choose the Linux App Name of LibGPIODInput. Also select the Architecture ARM 32-bit. Add a Label and Textfield to Window1 and change the text.

Drag-and-drop a Timer onto Window1. That is it for the controls needed with this simple example.

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