I took my first step into basic robotics today - turning on and off lights. It is a pretty cool step as this concept is the foundation of embedded technology.
What´s that, you ask? Here is an interesting wiki description of the Internet of Things.
So, anyway, I used the basic circuit technology that I learned last week, added the basic coding with some modifications and came up with two different examples of controling the lights. Now imagine each light represents a motor function on a robot... very exciting.
This is also how people do those crazy christmas light shows like this.
I did have a minor glitch, however. As you watch the video you will notice that the 4th light doesn´t light up. I made all of the obvious adjustments like changing the LED, changing the wire, changing the circuit and checking the code. None of that has worked yet and I hope there isn´t a hardware error on the 5th pin of my Arduino microcontroller... I will report back on that.
So here is my light show...
Here is the code I used for the second progression in the video above:
/*
Blinking LED Lights
*/
void setup () {
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
}
void loop() {
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
digitalWrite(3, HIGH);
delay(1000);
digitalWrite(3, LOW);
delay(1000);
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
delay(1000);
digitalWrite(5, HIGH);
delay(1000);
digitalWrite(5, LOW);
delay(1000);
digitalWrite(6, HIGH);
delay(1000);
digitalWrite(6, LOW);
delay(1000);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(8, LOW);
delay(1000);
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}
No comments:
Post a Comment