I just got my first Arduino kit today, and I've been messing with the very first example programs.
On the second one, the digital read / write one, I decided I'd put in a couple "for" loops to make it output faster, then slower, then faster, and so on. That worked, so I decided I'd put in a third "for" loop to blink an LED. It turns the LED on and back off, but no blinky.
Here's the code:
/*DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial
monitor
This example code is in the public domain.
*/
//digital pin 2 has a pushbotton attached to it. Give it a name.:
int pushButton = 2;
// Digital pin 7 will power an LED, give it a name
int LED = 7;
// the setup routine runs once when you press reset:
void setup() {
//initailize serial communication at 9600 bits per second:
Serial.begin(9600);
//make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
//Make the LED's pin an output
pinMode (LED, OUTPUT);
}
void loop(){
//read the button as an imput:
//print out the state of the button
for (int i = 0; i < 100; i++)
{
int buttonState = digitalRead(pushButton);
Serial.println(buttonState);
delay(100);
}
for (int i = 0; i < 10; i++){
int buttonState = digitalRead(pushButton);
Serial.println(buttonState);
delay(1000); //delay a little longer to see the difference:
}
for (int t = 0; t < 100; t++){
digitalWrite(LED,HIGH);
delay(10);
digitalWrite(LED,LOW);
}
}
That's all there is. I've fiddled the counts and times with the LED's loop, no change. It comes on once, goes off once, and the program resumes its happy circle.
What have I done wrong here?
Thanks,
Jeff