Arduino LED Testing

Background

To control the robot I will be using an Arduino platform that uses open source software to develop custom electronic devices. Code is written on a computer and then uploaded and stored in the Arduinos memory and run when the board is powered.

Activity

I bought an Arduino platform online and received it today, so thought to give it a try as I have never used an electronic platform before. I followed a simple LED Blink tutorial at http://arduino.cc. This introduced me to the basics of Arduino.
The code i used can be seen below and was used from http://arduino.cc/en/Tutorial/Blink.


 /*  
  Blink  
  Turns on an LED on for one second, then off for one second, repeatedly.  
  This example code is in the public domain.  
  */  
 // Pin 13 has an LED connected on most Arduino boards.  
 // give it a name:  
 int led = 13;  
 // the setup routine runs once when you press reset:  
 void setup() {          
  // initialize the digital pin as an output.  
  pinMode(led, OUTPUT);     
 }  
 // the loop routine runs over and over again forever:  
 void loop() {  
  digitalWrite(led, HIGH);  // turn the LED on (HIGH is the voltage level)  
  delay(1000);        // wait for a second  
  digitalWrite(led, LOW);  // turn the LED off by making the voltage LOW  
  delay(1000);        // wait for a second  
 }  

At first it did not work as i had not put the resistor in correctly having never played with electronics before i expected to encounter these problems.

From the simple code above I modified it to allow for 3 LEDs to flash in sequence.


 int RED = 13;  
 int YELLOW= 12;  
 int GREEN= 11;  
 // the setup routine runs once when you press reset:  
 void setup() {          
  // initialize the digital pin as an output.  
  pinMode(RED, OUTPUT);     
  pinMode(YELLOW, OUTPUT);     
  pinMode(GREEN, OUTPUT);     
 }  
 // the loop routine runs over and over again forever:  
 void loop() {  
  digitalWrite(RED, HIGH);  // turn the LED on (HIGH is the voltage level)  
  delay(1000);        // wait for a second  
  digitalWrite(RED, LOW);  // turn the LED off by making the voltage LOW  
  delay(1000);        // wait for a second  
  digitalWrite(YELLOW, HIGH);  // turn the LED on (HIGH is the voltage level)  
  delay(1000);        // wait for a second  
  digitalWrite(YELLOW, LOW);  // turn the LED off by making the voltage LOW  
  delay(1000);        // wait for a second  
  digitalWrite(GREEN, HIGH);  // turn the LED on (HIGH is the voltage level)  
  delay(1000);        // wait for a second  
  digitalWrite(GREEN, LOW);  // turn the LED off by making the voltage LOW  
  delay(1000);        // wait for a second  
 }  

Conclusion

I am pleased with the initial progress made in using a technology that was alien to me at first and have developed more confidence in the future of the project. I will continue to experiment with different configurations with the LEDs and coding of the Arduino.

Next Step

The next step is to continue learning about and using the Arduino platform with servos and I already have some that I can work on.






Comments

Popular Posts