Halloween Waving Pumpkin Arms Using Micro Servos and Arduino Nano With 3D Printed Parts

by led wiz in Circuits > Arduino

165 Views, 1 Favorites, 0 Comments

Halloween Waving Pumpkin Arms Using Micro Servos and Arduino Nano With 3D Printed Parts

image0.jpeg
Waving Servos.png

I was looking to add waving arms to a pumpkin without needing to carve it. I wanted the project to be an intro to servos and Arduino programming that was inexpensive and easy for those with a 3d printer.

Supplies

battery.PNG
minibreadboard.PNG
miniservo.PNG
nano.PNG
wirekit.PNG

Battery Holder $6 for 2

https://www.amazon.com/LAMPVPATH-Battery-Holder-Leads-Wires/dp/B07T7MTRZX/

Arduino Nano $13

https://www.amazon.com/Deegoo-ATmega328P-Microcontroller-Board-Arduino/dp/B07R9VWD39/

Mini solderless breadboard $7 for 6

https://www.amazon.com/Eiechip-Breadboard-solderless-breadboard-Arduino/dp/B07RSBPFN7/

Assorted wiring kit $6

https://www.amazon.com/EDGELEC-Breadboard-Optional-Assorted-Multicolored/dp/B07GD2BWPY/

2 Micro servos $8 for 4

https://www.amazon.com/Micro-Servos-Helicopter-Airplane-Controls/dp/B07MLR1498/

4 paperclips, twist ties, or 18 gauge wire to attach servo holder pieces

Printing and Assembly

image1.jpeg
3d printed.PNG
Capture.PNG
image4.jpeg
image5.jpeg
image3.jpeg
image2.jpeg

3d print the linked parts in the STL files.

The stand and hand should be mirrored to print the other one.

The stands can be fastened together with 18 gauge wire, twist ties, or paperclips as shown in the pictures.

The servos can be inserted in the rectangle openings, and the hands secured to the servos. Trimming or adding some hot glue can assist in the securing of these items if necessary.

Wiring and Programming

Waving Servos.png

Wire the Arduino Uno or Nano as shown in the diagram.

Download and install Arduino Software from https://www.arduino.cc/

The code is listed as a .ino file and below. This code works for both a nano and a uno, but the holder in the 3d printed file is for a nano. The .brd file below can be utilized using https://www.tinkercad.com/dashboard where the code and the diagram are dynamic showing the servos turning.


If you are new to Arduino, start here after installing the software:

https://www.arduino.cc/en/Guide


Code:

It is best to paste this in to notepad to remove any formatting before inserting it into the Arduino software.


// Alternate servos waving hands Works for Nano and Uno as both have PWM at 3&5

#include <Servo.h>

Servo leftarm;  // create two servos

Servo rightarm; // create two servos

int posleft = 120;  // variable to store the servo position for left arm

int posright = 180;  // variable to store the servo position for right arm.  

 // Because the arms are opposite and facing out, 

 // the angles can be separately adjusted for starting point speed, 

 // and direction

void setup() {

 leftarm.attach(3); // attaches the servo to pin 3 - PWM output

 rightarm.attach(5); // attaches the other servo to pin 5 - PWM output

}

void loop() {

 for (posleft = 120; posleft <= 180; posleft += 1) { // goes from 120 degrees to 180 degrees

   // in steps of 1 degree

  leftarm.write(posleft);       // tell servo to go to position in variable 'posleft'

  delay(15);              // waits 15 ms for the servo to reach the position

 }

 for (posleft = 180; posleft >= 120; posleft -= 1) { // goes from 180 degrees to 120 degrees

  leftarm.write(posleft);       // tell servo to go to position in variable 'posleft'

  delay(15);              // waits 15 ms for the servo to reach the position

 }

 for (posright = 180; posright >= 120; posright -= 1) { // goes from 180 degrees to 120 degrees

  rightarm.write(posright);       // tell servo to go to position in variable 'posright'

  delay(15);               // waits 15 ms for the servo to reach the position

 }

 for (posright = 120; posright <= 180; posright += 1) { // goes from 120 degrees to 180 degrees

     // in steps of 1 degree

  rightarm.write(posright);       // tell servo to go to position in variable 'posright'

  delay(15);               // waits 15 ms for the servo to reach the position

 }

}





Animate!

image1.png

Insert the 4 AA batteries, place the electronics in a ziplock bag if putting it outside, and it will animate!

You can utilize this as a staring point. See the video of our Halloween pumpkin stage here: