I wrote the software «DarthThreePointZero.ino» for «Darth 3.0: A 3D Printed Animated Darth Vader Helmet» in the Arduino 1.8.13 environment on MacOS Big Sur. I designed the software for no external libraries (dependencies) in the hope that it was easier for everyone to compile and download.

To compile and download the software to the ESP32, I connected a USB cable between my computer and the ESP32, loaded «DarthThreePointZero.ino» into the Arduino environment, then pressed the right arrow button to compile and download the software into the ESP32.

The software is divided into a number of sections, the first of which is the «Constants» section defining pin numbers, interrupt service routines timer modes and submodes, animation commands, and stepper motor parameters.

The second section «Global Variables» defines global variables for interrupts and slices.

The third section «Interrupts» contains the interrupt service routine «onTimer». This routine performs all aspects of homing the slices and executing step commands received from the Arduino «loop» function.

The third section «Arduino» contains the standard Arduino setup and loop functions. In the setup function, pin assignments are created and the interrupt service routine is established and created with a semaphore for the Arduino loop function. The Arduino loop function is designed to execute an array of animation commands. It steps sequentially through the «AnimationCommands[]» array and executes each animation command in sequence upon completion of the previous animation command as determined by receiving a semaphore from the interrupt service routine «onTimer».

The final section «Utilities», contains subroutines designed only for the interrupt service routine including «MotorSlice01Off()» designed to turn the slice01 motor off, «MotorSlice01Step» designed to step the slice01 motor one step, «MotorSlice18Off()» designed to turn the slice18 motor off, and finally «MotorSlice18Step» designed to step the slice18 motor one step.

Leave a Reply