Blinking an LED on arduino

820 604 Richard osamudiamen

This circuit uses the built-in LED that most Arduino have. This LED is connected to a digital pin and its number may vary from board type to board type. To blink an LED, you need to build this circuit, where you connect one end of the resistor to the digital pin correspondent to the constant you assign the LED . Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor. Connect the short leg of the LED (the negative leg, called the cathode) to the GND. In this circuit we will be blinking five LEDs. In the diagram below we show an UNO board that has D9, D10, D11,D12, D13 as the assigned value.    

The value of the resistor in series with the LED may be of a different value than 220 ohm; the LED will lit up also with values up to 1K ohm.  

    Code

After you build the circuit plug your Arduino board into your computer, start the Arduino Software (IDE) and enter the code below. The first thing you do is to initialize LED pin as an output pin with the line and assigning it to a number 

pinMode(pin1, OUTPUT);

In the main loop, you turn the LED on with the line:

digitalWrite(pin1, HIGH);

This supplies 5 volts to the LED anode. That creates a voltage difference across the pins of the LED, and lights it up. Then you turn it off with the line:

digitalWrite(pin1, LOW);

That takes the pin1 pin back to 0 volts, and turns the LED off. you want enough time for a person to see the change, so the delay() commands tell board to do nothing for 1000 milliseconds, or one second. When you use the delay() command, nothing else happens for that amount of time

        void setup() {

// initialize digital pin, pin1as an output.

pinMode(pin1, OUTPUT );

}

// the loop function runs over and over again forever

void loop () {

digitalWrite (pin1,

HIGH ); // turn the LED on (HIGH is the voltage level)

delay (1000);

// wait for a second

digitalWrite (pin1,

LOW ); // turn the LED off by making the voltage LOW

delay (1000);

Osamudiamen1
AUTHOR

Richard osamudiamen

All stories by: Richard osamudiamen
11 comments
  • gamefly
    REPLY

    hello there and thank you for your info – I have certainly picked up
    something new from right here. I did however expertise a
    few technical issues using this web site, since I experienced to reload the website
    lots of times previous to I could get it to load properly.
    I had been wondering if your hosting is OK?
    Not that I’m complaining, but sluggish loading instances times will very frequently affect your placement in google and can damage your
    high quality score if advertising and marketing with Adwords.

    Anyway I’m adding this RSS to my e-mail and can look out for much more
    of your respective interesting content. Ensure that you update this again soon.

  • JonathonBig
    REPLY

    Hello. I have checked your learnit.org.ng
    and i see you’ve got some duplicate content so probably it
    is the reason that you don’t rank high in google.
    But you can fix this issue fast. There is a tool that creates content like
    human, just search in google: miftolo’s tools

  • gamefly free trial
    REPLY

    Hi! I’ve been reading your blog for a long time now and finally got
    the courage to go ahead and give you a shout out from
    Porter Texas! Just wanted to tell you keep up the good work!

  • gamefly free trial
    REPLY

    Oh my goodness! Awesome article dude! Many thanks, However I am having problems with your RSS.
    I don’t understand why I can’t subscribe to it. Is there anybody else having identical RSS
    issues? Anyone that knows the answer will you kindly
    respond? Thanks!!

  • plenty of fish dating site
    REPLY

    Hello there! I could have sworn I’ve been to your blog before
    but after looking at many of the articles I
    realized it’s new to me. Anyways, I’m certainly happy I stumbled
    upon it and I’ll be bookmarking it and checking back frequently!

Leave a Reply

Your email address will not be published.