Pages: [1]   Go Down
Author Topic: confused about order of operations in blink demo [solved]  (Read 654 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm playing with the built-in blink example, and am confused about why things are working as they are.  In the following code snippet:

Code:
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(4000);               // wait for a second
}

I would expect this to light up the LED, wait for 1 sec, then turn it off and wait for 4 sec.  However, the opposite is true.  It lights up, stays lit for 4 seconds, then turns off and waits for 1 second.

I a little bit feel like I'm going crazy here.  Why is it reverse of what I expect?
« Last Edit: January 09, 2013, 01:47:51 am by Nick Gammon » Logged

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2627
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is your LED with resistor going to ground?
Logged

The way you have it in your schematic isn't the same as how you have it wired up!

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ah, that was it.  thanks!
Logged

Pages: [1]   Go Up
Jump to: