Analog Arm 2D is an interactive installation that lets you drive a two-segment robotic arm in Processing using a simple analog joystick. As you tilt the joystick, the arm’s joints rotate in real time and the window’s background color shifts smoothly based on the joystick’s X and Y positions.
https://analogarm2d.netlify.app/
What is this project about?
Why did we build it?
Visual feedbackIntegrating Processing to display live sensor data was both a creative challenge and an excellent way to gain hands-on experience with real-time graphics and color mapping.
Educational robotics demoWe want to inspire students and makers to see how a few lines of code and an inexpensive joystick can produce compelling, interactive graphics.
How does it work?
- On the hardware side, the joystick’s X axis is wired to GPIO29 (ADC channel 3) and the Y axis to GPIO27 (ADC channel 1) on the Dual MCU (RP2040).
- In
main.py
, we calibrate the joystick’s center point, scale raw ADC readings to the –50…+50 range, then stream comma-separatedvx, vy
pairs over USB serial at 115200 baud every 50 ms.
In the Processing sketch (arm.pde
), we continuously read vx
and vy
, compute simple inverse-kinematics to calculate each joint angle, and redraw the arm. The background color is updated with:
background(
map(vx, -50, 50, 0, 255), // Red channel
0,
map(vy, -50, 50, 0, 255) // Blue channel
);
Here’s a step-by-step guide to help you get started with the AnalogArm2D joystick-controlled web visualization using the Dual MCU board:
- Connect X-axis of the joystick to GPIO29
- Connect Y-axis to GPIO27
- Power the DualMCU via USB
- Open Thonny IDE (or your preferred MicroPython editor).
- Select Interpreter →
MicroPython (Raspberry Pi Pico)
- Create a new file and paste the provided MicroPython code (assumed you already have it).
Save it to the board:
File → Save As… → Raspberry Pi Pico → main.py
⏳ The board will automatically reboot and start sending scaled vx
, vy
values over the USB Serial port.
Open your browser and go to:
🔗 https://analogarm2d.netlify.app/
- Click the “Connect Serial” button.
- If prompted, select the COM port for the Dual MCU.
Once connected:
- A 2-segment robotic arm will appear.
- Move the joystick to control the arm and change the background color in real time.
If you’d like, I can also provide or review the MicroPython code that handles joystick input and serial output. Just let me know!
Comments