This project enables basic operation of two Traffic Light modules with a Raspberry Pi running QNX. It includes samples in both Python and C that do exactly the same thing. It assumes you are working on the QNX Developer Desktop, or a similar self-hosted target.
See the Project Slides PDF in the root of this repo for more information. If you're attending a QNX workshop in person, these slides match what the presenter is showing in-person.
- Traffic lights illuminate and the sets alternate quickly, in the style of a simulated intersection
- Stopping the program (SIGINT) shuts off all LEDs
- On your QNX target, make a working folder (ex.
pihardware) and clone this repo into it (resulting inpihardware/traffic-lights):git clone https://github.com/qnx/workshop - In the same working folder, clone the Raspberry Pi Hardware Component Samples repo that contains many Raspberry Pi hardware samples and some common libraries (resulting in
pihardware/Raspberry-Pi-Hardware-Component-Samples)git clone https://github.com/qnx/Raspberry-Pi-Hardware-Component-Samples - Assemble the hardware per the Circuit Diagram below
- For Python, navigate to the
python/directory from this repo and runpython traffic-lights.py - For C, navigate to the
c/directory from this repo and runmake allto build the project. To run the sample, look for the binary in thebuild/directory (./build/aarch64le-debug/traffic-lights).
The GPIO pins used in the sample were chosen specifically to be adjacent pins, for easier connections. For a diagram of Raspberry Pi GPIO numbers, see: https://pinout.xyz/
If you choose to customize the GPIO pins you use, make sure to update the code with the matching GPIO pins.
- GND is connected to the GND pin of the Raspberry Pi.
- R is connected to GPIO 16 of the Raspberry Pi.
- Y is connected to GPIO 20 of the Raspberry Pi.
- G is connected to GPIO 21 of the Raspberry Pi.
- GND is connected to the **GND pin of the Raspberry Pi (bottom corner).
- R is connected to GPIO 26 of the Raspberry Pi.
- Y is connected to GPIO 19 of the Raspberry Pi.
- G is connected to GPIO 13 of the Raspberry Pi.