Halloween Hackery

Building a foot controlled sweet dispensing robot from junk box parts.

I had some time off during the last week of October and during a morning run got a brainwave that I could bodge together a foot controlled sweet dispensing robot for socially distanced Trick or treating!

The Electronics

The basic idea was to use some sort hopper and a rotating tumbler. I needed a controller, a motor and a driver as a starting point. So I set about taking apart an old hacked together motor controller prototype from 2015 that was in the junk box, as it had a Teensy 3.1 and several stepper motor drivers on the board.

The de-soldering a bit more difficult than I expected...

But eventually the Teensy 3.1 was free! I love the Teensy series of microcontroller modules for throwing together hardware prototypes as they are very versatile and I was lucky to have one in the junk box (it probably shouldn't have been in the junk box to be fair).

My makeshift workbench was definitely not something Health and Safety would approve of. Please do not do soldering on a small collapsible table.

After a bit more work I freed up one of the motor drivers...

Right, enough soldiering in precarious conditions. To the breadboard! So I needed to build a little motor controller for the an old printer stepper motor than was also in the junkbox. The motor was from an Epson printer, Googling the model number printed on the back of the stepper motor got me to a page which had the basic specs. It's a 7-Volt, 1.8' per step stepper motor for a printer.

I wired up the salvaged stepper motor driver module for minimal 2-wire control according to the diagram available on the Pololu website, running from digital outs 15 and 16 on the Teensy.  I then attached a junk box microswitch to digital input 2 on the Teensy.

After some experimentation and a little frustration with the AccelStepper and Bounce libraries in the Arduino IDE I managed to get the motor to rotate 180' when the microswitch was pressed. The main problem I had was figuring out how to setup an AccelStepper instance so that the motor rotated a half turn at a constant speed, rather than accelerating and declerating.


To be continued tomorrow...