Know where you're going?

Step 1.
Step 2.
Navigate

Yay! The arduino!

This tutorial assumes that you have an arduino uno and have already downloaded and installed the arduino software. If you haven’t done this then refer to www.arduino.cc for information about downloading the sofware as well as the link to dowload for free.

Step 1:

Now that you have everything ready to go we can start with the fun stuff. Programming. First what we want to do is go ahead and open up the arduino application on your computer (if you haven’t already). Once you’re there, copy this code into your program.

#include ‹Servo.h›

Servo servoMain; // Define our Servo
Servo servoSecond;// Define our Servo

int x = 1;

void setup()
{
   servoMain.attach(10); // Dimmer switch servo on digital pin 10
   servoSecond.attach(9); // Feed servo on digital pin 9
}

void loop()
{
  if (x == 1) { // If statement will make it's contents run only once
    servoMain.write(0); // Turn dimmer switch servo right
    delay(450); // Wait .45 Seconds
    servoMain.write(180);// Turn dimmer switch servo left
    delay(225); // Wait .225 seconds
    servoMain.write(89); // Stop dimmer switch servo
    delay(1000); // Wait 1 second
    x = 0; // Makes sure this if statement will not run again
  }
  /*
  * When the code says "servoSecond" the number in parentheses
  * is the degree to which your servo will turn then stop
  *
  * When the code says "servoMain" if the number in parentheses
  * is ‹ 89 then the servo will continuously turn to the right
  * if the number in parenthesis is > 89 then the servo will turn
  * continuously to the left
  * if number in parenthesis is == 89 then the servo will stop.
  * ***** Note: you may have to adjust 89 to get it to stop  *****
  * ***** as it is different for every 360 servo, try 90 next *****
  * ***** it may get as high as 25 units away from 89.      *****
  */
  delay(1000);
  servoSecond.write(90);
  delay(1000);
    servoSecond.write(0);
    delay(300);
    servoSecond.write(90);
    delay(3000);
    servoSecond.write(0);
    delay(300);
    servoSecond.write(90);
      servoMain.write(0);
      delay(400);
      servoMain.write(89);
    delay(2650);
    servoSecond.write(0);
    delay(300);
    servoSecond.write(90);
    delay(3000);
    servoSecond.write(0);
    delay(300);
    servoSecond.write(90);
    servoMain.write(180);
      delay(350);
      servoMain.write(89);
    delay(15000);
}
    

All details about are the program are commented in the code after // or *. Now, just to be safe go up to File and select Save As. Save your program as whatever you want as it is not important to the later steps. Now that you have done this press the checkmark button at the top of the program to verify your code. If it does not verify (errors will appear in orange) then go back and double check that you have used our exact code. Once it is verified plug in your arduino and press the arrow pointing right (next to the verify button) to upload to the board. If you are having problems with that and you can’t upload to you board then please refer to this very helpful link www.instructables.com

Step 2:

Now lets get everything wired up. Lets first get “servoMain” wired up. If you haven’t already guessed, the “servoMain” is the servo that we will be attaching to the dimmer switch. The wiring goes as follows:

Black - GND; Red - 5v; White - Pin 10

Next, lets hook up the “servoSecond”, this one is a bit more tricky but you can do it if you pay attention. You will need your external power source for this part. Go ahead and cut the tip off and strip both of the wires. Once you do this Connect the following:

Brown - Black (On power strip) - GND; Orange - Red (On power strip); Yellow - Pin 9

Once you do this you will see that your program and circuit works!

Congratulations! You are done with the arduino!

To Home

About | Credits - Home Page Image by Joshua Earle, Looking Man Mountains, 3/20/15, Creative Commons Attribution
- Materials Page Image by Caleb George Morris, Blur Chilling City 1698, 3/20/15, Creative Commons Attribution