Arduino Arcade Servo

Supplies needed:

*Arduino module (any with PWM)


*Diode (optional - just in case)

*External power source




*& USB cord that might have come with Arduino

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Wiring

Connect the cable from the Joystick to the Arduino (wiring may vary, use your datasheet or experiment with LEDs to figure out your wiring or use the Arduino with the basics with a digital button example). My wiring is like in the picture up above. The servo's yellow wire goes to Arduino pin 52, this is not set and stone, so you can change it if you need or want to. The servo's red wire goes to the INDEPENDENT 5V source. The black wire from the servo goes to the GND of BOTH the Arduino & 5V source. Make sure to also connect a power supply to your Arduino when you are finished uploading your sketch, or leave it on your computer, your choice.

Step 2: Code

#include "Servo.h" // define the Servo library

#define Up 44 // Define joystick wiring

#define Down 45

#define Left 46

#define Right 47

Servo Servo1; // define servo object

void setup() {

pinMode(Up, INPUT_PULLUP); // define the pins of the joystick as input with

pinMode(Down, INPUT_PULLUP); // a pullup resistor which basically reads the joystick better

pinMode(Left, INPUT_PULLUP);

pinMode(Right, INPUT_PULLUP);

Servo1.attach(52); // attach the servo to pin 52 }

void loop() {

while (digitalRead(Up) == LOW){ // while the "Up" button is pressed

Servo1.write(90); // make the servo go to 90 degrees or a right angle

} digitalWrite(52, LOW); // Make the pin go low for no holding torque or holding position the

same technique goes for the rest just different angles

while (digitalRead(Down) == LOW){

Servo1.write(90); }

digitalWrite(52, LOW);

while (digitalRead(Left) == LOW){


} digitalWrite(52, LOW);

while (digitalRead(Right) == LOW){

Servo1.write(180); }

digitalWrite(52, LOW); }

Step 3: Questions?

Be the First to Share


    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest