Hello,
Because this is my first post, first a little intro and after that, my question.
Since a few week I joined the wonderful world of Arduino. (I love the little stickersheet that comes with it) I came to know about the Arduino, when i did read a story about a DIY Ambilight for your computer. After reading that story, I became enthousiast and started reading about Arduino. After reading examples, projects etc. I became more and more enthousiast and decidet to step in to the world of Arduino. I have a few goals (projects) in mind like the ambilight, rgb-led-cube, weatherstation and my ultimate goal a like the mars-mission-rover-robot who also can talk. But in order to get those kind of projects working, there are some basics to learn. (In my case a lot i guess )
So after following a few tutorials I did try to make my own first little project, instead of letting 1 led blink I wanted to make 4 RGB Leds blink in sequence looping through the colors.
I layed the following out on my breadboard:
And i edit the blink example code in this:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop() {
digitalWrite(0, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(0, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(1, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(1, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(2, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(2, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(3, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(3, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(4, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(4, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(5, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(5, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(6, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(6, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(7, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(7, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(8, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(8, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(9, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(9, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(10, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(10, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(11, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(11, LOW); // set the LED off
delay(1000); // wait for a second
}
When I did run the program, it suprised me that all leds where on, every color, so they turned white (that's normal) Than everything worked as what i did have in mind. Led by Led, looping through the colors. So after this experiment I have a few questions:
Did I layout a correct schematic? (the wiring)
I used one resistor (1K Ohm) on the +3,3v is that enough? / correct?
I asume that the reason why all the Leds where on at first, is because I used the +3v.v and not the ground pin?
On the programming part: I understand, this peace of coding could be done in a more effective way, like replacing delay(1000) with delay(TIME) placing the delay(TIME)=1000 with the int statement in the setup?
I do have some more questions, but I think for the moment this is enough. With asking these questions I'm hoping to find out, if i am on the "right" track, that my way of thinking is correct.
Thanks for now!
M