Useless Machine - Arduino

3 minute read

Published:

A Tkinter-based Arduino control hub for the useless machine and the DC motor position control interface.

  • a classic useless machine that reacts to physical switches with a servo and stepper carriage
  • a DC motor position control interface with P / PI control and live plotting through Banyan

The main application starts with a hardware keypad login, then routes the user into a menu where each activity can be launched, stopped, and restarted independently.

Useless machine hardware

Project Overview

The repository is organized around a few focused modules:

  • global_interface.py is the main GUI application. It handles keypad authentication, the activity menu, runtime switching, and the live status dashboard.
  • keypad.py contains the keypad scanner abstraction used by the login flow.
  • machine.py drives the useless machine hardware: switches, stepper, and servo.
  • motor.py contains the DC motor, potentiometer, and fixed setpoint helpers.
  • motor_control.py implements the discrete P / PI position controller.
  • motor_plot.py publishes live motor telemetry over Banyan.
  • motor_plot_subscriber.py displays the live response plot in a separate process.
  • archive/ keeps older experiments and previous interfaces for reference.

Features

Keypad login

  • Callback-based key detection to avoid noisy polling on every edge.
  • Timeout handling, input clearing with *, and shutdown request with D.
  • A simple digit-code flow before the main menu unlocks.

Keypad detail

Useless machine mode

  • Stepper homing on startup for a stable reference point.
  • Switch-driven behavior that moves the carriage to the active switch position.
  • Servo deploy / retract sequence with automatic return-to-home after inactivity.
  • Live telemetry in the GUI for switch states, home state, position, and action text.

Useless machine mode in the GUI

DC motor mode

  • Manual or PC setpoint source selection.
  • P and PI controller modes with tunable Kp and Ki.
  • Anti-overreaction limits with bounded PWM output.
  • Wrapped ADC error computation for circular position behavior.
  • Live response publishing to a separate subscriber window.

DC motor hardware

Motor control graph examples

Motor response plot - tuned transient

Motor response plot - steady response

Media

Demo videos

Highlights

Keypad

  1. Callback Triggered (just mark a flag, avoiding noise callback)
  2. Main polling loop (check flag, execute action, reset flag)

DC Motor

The live plotting is decoupled from the main GUI to allow continuous updates without freezing the interface, using Banyan for inter-process communication.

  1. 0 & 1023 corner cases
  2. Limited max pwm for no overreaction
  3. Banyan: set, measure, timestamp
  4. Kp, Ki (erase gap)

Useless Machine

The useless machine logic is event-driven, responding to switch state changes and automatically returning to home after inactivity.

  1. Callback Homing - No strange noise (at the beginning)
  2. Smooth Movement

Overall

The code is organized into focused modules for hardware control, GUI management, and control logic, making it easier to maintain and extend.

Hardware / Software

You will need:

  • Arduino board running Firmata-compatible control via pymata4
  • Matrix keypad
  • DC motor with driver stage
  • Potentiometers for position measurement and command input
  • Stepper motor, servo, and switches for the useless machine mechanism
  • Python packages: pymata4, matplotlib, and python-banyan

tkinter is used for the GUI and is typically included with standard Python installations.

How To Run

Start the Banyan backplane first, then launch the plot subscriber, then the GUI:

# 1
backplane

# 2
python ./motor_plot_subscriber.py

# 3
python ./global_interface.py

The GUI starts on the keypad login screen. After authentication, use the menu to enter either activity.

Suggested Workflow

  1. Start the backplane.
  2. Open the motor plot subscriber in a separate terminal.
  3. Launch the global interface.
  4. Use the keypad to log in.
  5. Choose either Useless Machine or DC Motor from the menu.

Notes

  • The keypad code is defined in global_interface.py and can be changed there.
  • The separate plot window is intentionally decoupled from the GUI so the motor interface can keep running while the live graph updates.
  • The archive/ folder contains legacy versions of earlier keyboard and motor interfaces.