L.O.A.S.H’s Arduino Projects: Controlling Servo Motors with a Joystick

With this project, you will be able to control two servo motors with a joystick with Arduino! 

For this project you will need to gather:

  • Arduino Board


  • Breadboard


  • Wires | x13


  • Servo Motors | x2


  • Battery 



To make this (really cool) project, you will need to:

Step 1: Battery

Connect your external battery to your breadboard.


Step 2: Wiring 

Get a piece of wire and connect one end to GND on your Arduino Board and the other end to the negative channel on your breadboard.


Step 3: Servo Motors

Get your two servo motors and 6 wires. Connect the VCC and the GND of the two servos to the VCC and GND on the breadboards inputs. Then, connect your first Servo Signal Connect to the Arduino Digital PMW 3 on your Arduino Board.


 In case you aren’t very familiar with the Arduino Digital PMW 3, it looks like the photo below as well as the Digital PMW 5 and the blue wire from the first servo


Your second Servo Signal Connect should be connected to the Arduino Digital PMW 5.


Step 4: JoyStick

Connect the GND on your Joystick to the GND on the Arduino Board.


Then, connect the +5V on your joystick to the 5V on the Arduino Board.

Then, connect the VRx on your joystick to the A0 on the Arduino Board.

Then, connect the VRy on your joystick to the A1 on the Arduino Board.

The photo below shows where I connected what and where. Just look at the corresponding colors to which wire and the connection.


It also looks something like this….

Screen Shot 2017-07-03 at 13.40.11


Step 5:  The Code

Open up your Arduino on your computer and copy the code below:

//add the servo library
#include <Servo.h>

//define our servos
Servo servo1;
Servo servo2;

//define joystick pins (Analog)
int joyX = 0;
int joyY = 1;

//variable to read the values from the analog pins
int joyVal;

void setup() 

{ //attaches our servos on pins PWM 3-5
servo2.attach(5); }

void loop() 

{ //read the value of joysticks (between 0-1023)
joyVal = analogRead(joyX);
joyVal = map (joyVal, 0, 1023, 0, 180);

joyVal = analogRead(joyY);
joyVal = map(joyVal, 0, 1023, 0, 180);
delay(15); }

Screen Shot 2017-07-03 at 13.54.02

Step 6: Verify, Connect and Upload

Once you verify and save the code, you can connect your Arduino board to your computer and upload the code to your board. Tada! 

Step 7: Have fun and Experiment

Yay! We’ve finally finished yet another Arduino Project. You guys are so awesome! Now, after playing around with this, you can try to experiment maybe add more things (an example, “lights, perhaps?”).

Wait, if you are having any problems uploading or your project isn’t functioning properly, you should double check your wiring and maybe check which Port your Arduino (on your computer) connected to in the tools. If there is anything else don’t be shy to comment down below!

Screen Shot 2017-07-03 at 13.57.45


Yours truly, 




Project Python | Command Line Calender

You can make your own calendar and even add, update and view.

For your python code, copy and paste the following:

from time import sleep, strftime
name = “Libster”calendar = {}
def welcome():    print(“Welcome, ” + name + “!”)    print(“Calendar starting…”)    sleep(1)    print (“Today is “) + strftime( “%A %B %d, %Y”)     print (“The time is “) + strftime(“%I:%M:%S”)    sleep(1)    print(“What would you like to do?”)    def start_calendar():  welcome()  start = True  while start:    user_choice = raw_input(“Please choose A to Add, U to Update, V to View, X to Exit. “)    user_choice=user_choice.upper()    if user_choice == “V”:      if len(calendar.keys()) <1:        print “Your calendar is empty”      else:        print calendar    elif user_choice == “U”:        date = raw_input(“What date? “)        update = raw_input(“Enter the update: “)        calendar[date] = update        print(“Update successful.”)        print calendar    elif user_choice == “A”:        event = raw_input(“Enter event: “)        date = raw_input(“Enter date (MM/DD/YYYY): “)        if len(date) > 10 or int(date[6:]) < int(strftime(“%Y”)):            print(“Invalid date.”)              try_again = raw_input(“Try again? Y for Yes, N for No: “)            try_again = upper.try_again()            if try_again == “Y”:                continue            else:                start = False            else:            calendar[date] = event            print(“Event update successful.”)            print calendar    elif user_choice == “D”:        if calendar.keys(len(date)) < 1: #check this line if fail            print(“The calendar is empty.”)        else:            event = raw_input(“What event?”)             for date in calendar.keys():                if event == calendar[date]:                     del calendar[date] # deletes entire entry, inc date & event                print(“Event deleted.”)                print calendar            else:                print(“Incorrect date.”)    elif user_choice == “X”:        start = False    else:        print(“Invalid command.”)        breakstart_calendar()


Then in the command line, play your python code.

Screen Shot 2017-07-02 at 17.40.47

Above, the picture is an example of how it should turn out to be. I added an event, updated that same event and viewed! Don’t forget to try to experiment and maybe make this cooler.

Yours truly,