Introduction: Controlling an RC Servo Motor With an Arduino and Two Momentary Switches

The name says it all. Controlling an RC car servo motor with an Arduino and some resistors, jumper wires, and two tactile switches. I made this the second day I got my Arduino, so I'm pretty proud of myself.

Step 1: Parts List

Okay, your going to need the following:

Arduino-$30-35 USD
Find out where to buy those here.

Jumper Wires-$8.50 USD
I got mine from Amazon

Resistors- Pennies a piece
Get em from Radio Shack, Digi-Key, Mouser, Jameco, etc.
Your goin to need two around 100 ohms (brown black brown) and two around 10k ohms(brown black orange). These don't have to be exact.

Servo Motor- $10 USD
Yes, I know this isn't the cheapest one on the internet. Tower Hobbies

Breadboard- $9-$30 USD, Depending on the size.
Amazon

Tactile Switch- $0.20 USD
Only 6,427 left on Digi-Key I just salvaged mine...

Step 2: The Circuit

The circuit is fairly simple. You should be able to throw it on a breadboard in five minutes like I did. Make sure it makes no sense to your less geeky family, and looks like a wad of something you pulled off a drain snake. Yum.

Step 3: The Program/Sketch

Here's my code that I used. I might explain it later, I'm kind of lazy. Thats what this and this are for.


#include <Servo.h>

Servo myservo;
int button7=0;
int button6=0;
int pos=90;

void setup()
{
pinMode(7, INPUT);
pinMode(6, INPUT);
myservo.attach(9);
}

void loop()
{
button7=digitalRead(7);
button6=digitalRead(6);

myservo.write(pos);

delay(5);

pos=constrain(pos,0,180);

if(button7==1 && button6==0)
{
pos++;
}

if(button7==0 && button6==1)
{
pos--;
}
}

Any bugs, glitches? I don't notice any...

Step 4: It Works(or Doesn't)! And, Coming Soon.....

It hopefully works for you, if it doesn't post a comment. We of the instructable community are usualy good at helping people. Hoping to add a video sometime soon. Might just post a video of an Arduino controlling a servo in another project, since I've moved on to bigger and better things. So have fun with this, modify it, heck go out and make money off of it and then tell me! That would just make my day.