🛠 Advanced GPIO Control on Arduino UNO Q
Objectives
This tutorial aims to master low-level interaction between Modulino nodes and the Linux system of the Arduino UNO Q. You will learn to map physical inputs (buttons, joystick) to system events and control outputs (pixels) for complex haptic or visual feedback, going beyond simple mouse/keyboard emulation.
Required Hardware
- Arduino UNO Q SBC Controller Bundle (UNO Q 4GB board)
- Modulino Nodes: Buttons, Joystick, Rotary Knob, Pixels
- 24-pin USB-C cable
- 45W USB-C Power Supply
- 8-in-1 USB-C Hub (for SSH terminal access)
- Arduino App Lab environment installed
Steps
- Physical Connection: Assemble the UNO Q board in its 3D case. Connect Modulino nodes to dedicated ports. Ensure the USB-C hub is connected for network and display access.
- System Access: Open an SSH terminal to the UNO Q via its local IP. Verify peripheral detection using
lsusbto confirm Modulino presence.
- App Lab Configuration: Launch Arduino App Lab. Select the "Custom Controller" project. In the "Mapping" tab, associate the physical button with a specific keyboard key (e.g.,
KEY_ESC) and the joystick with mouse axes.
import hid dev = hid.device(vid=0x2341, pid=0x0050) dev.open_path(dev.enumerate()[0]['path']) print(dev.read(64))
- GPIO Control Script: For advanced control, create a Python script using the
hidapilibrary or direct GPIO interfaces if exposed. Example state reading:```python
5. **Dynamic Mapping**: Use `evtest` to monitor raw events. Create a `udev` rules file to trigger a shell script when a Modulino button is pressed, allowing system command execution (e.g., launching a Home Assistant app).
6. **Visual Feedback**: Configure Modulino pixels to light up based on system state. In App Lab, link the LED output to a logical GPIO signal or use a script to send HID LED control packets.
## Verification
Run `evtest` in the terminal. Press the Modulino button: you should see an `EV_KEY` event generated. Verify that pixels illuminate during action. If mapping fails, check udev permissions and restart the device management service.
## Going Further
Explore creating multiple profiles to switch between "Retro Gaming" and "Home Automation" modes. Integrate external sensors via extended GPIOs for increased environmental responsiveness.