Article Preview
Buy Now
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):
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 fileLibGPIODInput.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 logicalzero . 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 consideredoff . When the button on the breadboard is in the up position and more than half-a-second has passed, then theTextfield
has red text with the wordsButton Up
. When the breadboard button is held down and the update button is pressed after more than half-a-second then theTextfield
background changes to a green color and the textButton 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 aLabel
andTextfield
toWindow1
and change the text.Drag-and-drop a
Timer
ontoWindow1
. That is it for the controls needed with this simple example.
...End of Excerpt. Please purchase the magazine to read the full article.