Tuesday, July 03, 2012

Arduino project 1

Here's a fun little Arduino project that only takes a few minutes. Just note that this article assumes that you have an Arduino UNO. If you have any other kind of Arduino, adapt accordingly (I will give details on how to adapt throughout the article). Lets get started! First, take your Arduino and put 3 wires in ports 2, 3, and 4 (DO NOT put any wires in 0 or 1 or any port that has the words TX or RX next to it. Those ports are meant for serial communication to talk to things like LCD screens or EEPROM (external memory)). Then grab a breadboard (if you don't have one you can get one from Radio shack for less than $10 USD). Then take the 3 wires and put them into the breadboard. If you are not sure how or where to put the wires, Google "breadboard map" under Images and it gives a diagram of how all the holes are linked. Then take 3 LED's (jamaco.com for under $1 USD) and put the cathode (long leg) into the same row as the corresponding wire. Do the same for the other LED's. Now take 2 wires to connect all the short legs together. Then take 1 wire and and connect 1 end to the 2 wires you just placed, then take the other end and connect it to the header port labeled GND (on the UNO it's on the other side). Now turn on your computer and load the Arduino programming software (instructions at arduino.cc). Then, type in the following code:


void setup()
{
    pinMode(2, OUTPUT);
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
}
void loop()
{
    digitalWrite(2, HIGH);
    delay(1000);
    digitalWrite(2, LOW);

    digitalWrite(3, HIGH);
    delay(1000);
    digitalWrite(3, LOW);

    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(4, LOW);
}
Then send it to your Arduino (instructions at arduino.cc). Then press the reset button (if you are using an UNO, it does it automatically) and watch the lights light up. I'll upload a video soon. Have fun! If yours didn't work or you want to make a suggestion, comment below.

No comments:

Post a Comment