loading

Step 5: Make Your LED Blink!

The Arduino library provides another useful little function called delay. The delay function takes in the length of the delay -- an int (integer) value in milliseconds.

Combining the delay function with the loop function allows us to create a blinking effect with the LED.

We will do this by setting a delay of 1 second (1000 milliseconds) between the LED being on (HIGH) and the LED being off (LOW).

We're going to use an int variable named DELAY so that we can change its value without having to type in numbers over and over everywhere.


Example:

// variables
int GREEN = 3;
int DELAY = 1000;

// basic functions
voidsetup()
{
  // setup LED modes
  // we're specifying that we're going to send information to this LED
  pinMode(GREEN, OUTPUT);
}

voidloop()
{
  // High turns things on
  digitalWrite(GREEN, HIGH);
  delay(DELAY);
  // low turns things off
  digitalWrite(GREEN, LOW);
  
}

<p>is there a typo in your code? should it not be </p><p>digitalWrite(GREEN, HIGH);</p>
<p>I almost taught I'm the only one who noticed that mistake in the code at 4th step :)</p>
When i upload programming to arduino it gives error message.Arduino: 1.5.7 (Windows 7), Board: &quot;Arduino Uno&quot; <br> <br>Sketch uses 1,144 bytes (3%) of program storage space. Maximum is 32,256 bytes. <br> <br>Global variables use 15 bytes (0%) of dynamic memory, leaving 2,033 bytes for local variables. Maximum is 2,048 bytes. <br> <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x01 <br>avrdude: stk500_recv(): programmer is not responding <br>avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x01 <br> <br> This report would have more information with <br> &quot;Show verbose output during compilation&quot; <br> enabled in File &gt; Preferences.
<p>Nice one, very easy and very educative !</p>
<p>Your code isn&acute;t working on my breadboard. All connections, ports, pins we&acute;re double-checked. Could anything be out of place?</p>
<p>Very nicely done tutorial , thanks for sharing ! </p><p>Build_it_Bob</p>

About This Instructable

69,921views

50favorites

License:

Bio: Dream It! Build It! Teach It! AHA is a community workspace with shared tools and knowledge for Coders to Crafters to Makers to Hackers. We ... More »
More by allhandsactive:Arduino Street Traffic Light - Breadboard EditionBasic Human Scan with Kinect & ReconstructMe ConsoleDIY Heart Box!
Add instructable to: