Saturday, October 8, 2011

Circuit-01 Blinking LED

Purpose: To make one LED light blink on and off

Equipment: 

  • Arduino x 1
  • Breadboard x 1
  • Arduino Holder x 1
  • CIRC - 01 Breadboard Sheet x 1
  • 5mm Yellow LED x 1
  • Wire x 3
  • 330 Ohm Resistor x 1


References:



Program Details:
This experiment is the first one so it introduces all the basic concepts of arduino and circuits to a user. One concept it shows the user is that you a resistor should be placed in your circuit to avoid blowing up the LED or the arduino board. A second concept it shows is the concept of ground and positive electricity. A wire should be connected from digital ground into the negative column in the breadboard. This will ground all electricity coming into the whole column. The same applies to positive electricity, the entire column will become positive. A third concept explained is the LED position. The larger lead/pin must go into the positive energy flow and the shorted lead/pin must go into the ground. Finally, the last concept is that a wire may also be connected from any of the positive or negative column pins into one of the 30 horizontal rows and that will make the whole row positive or negative.

As well as hardware concepts, software concepts are introduced to the user as well. The first method, the void setup method, is used to initialize the program. The second method, pinMode, is used to set  a pin (determined by an integer) as an output. The third method, digitalwrite, uses the integer and makes the LED on that pin either turn on(HIGH) or turn off (LOW). The final method, delay, uses a number (in milliseconds) to delay time before running the next line of code. The last three methods are in loop meaning that they will run repeatedly as long as there is power connected to the arduino.  

To create Circuit-01, we simply followed the breadboard sheet. We first connected a wire from 5v to a pin on the positive column. Then we connected a wire from Digital Ground to a pin on the negative column. A 330 ohm resistor was placed from a negative pin into row 11. The only difference in our circuit was that we connected a wire from Pin11 instead of Pin13 into row 10.

Time to complete: 5 mins to set up Arduino Board
                               5 mins to write the program

Results: When the code was first inputted into the arduino, nothing happened.Soon after, it was discovered that we had not connected the wire to pin13 but rather to pin5 because we had skipped that step. So the program was fixed but the LED still didn't run. Then we discovered that the the LED was placed backwards, as in the longer lead was placed into the negative flow. After we switched that, the LED blinked and the exercise was completed.

Photo:

Tips:
  • Place LED leads correctly 
  • Make sure you have a resistor in your circuit
  • Make sure your programmed pins and your physical arduino pins are the same
  • Remember that Ground is negative and all PIN numbers are positive (this includes Analog Pins)
Further Work: I will change the delay times in the program as well as add more code to the loop to see the capabilities of the LED. 


Program Modifications:
The program is almost the same as the program in the link below.
The only modifications were the change from PIN13 to PIN11.


Program:
int pin11 = 11;                                            // Holds the Pin number that the LED is connected to

void setup()
{
  pinMode (pin11, OUTPUT);                        //Assigns the pin with an output
}// ends the void setup method

void loop()
{
  digitalWrite(pin11, HIGH);                        // Turns on the LED at pin11 
  delay (1000);                                          // Creates a delay for 1000 milliseconds / 1 second
  digitalWrite(pin11, LOW);                        //Turns off the LED at pin11
  delay(2000);                                          //Creates a delay for 2000 milliseconds / 2 seconds
}// this ends the loop

No comments:

Post a Comment