Getting Started with Arduino Uno

Getting Started with Arduino Uno

LEDs are small, powerful lights that are used in many different applications. To start off, we will work on blinking an LED, the Hello World of microcontrollers. That’s right – it’s as simple as turning a light on and off. It might not seem like much but establishing this important baseline will give you a solid foundation as we work toward more complex experiments.

Things You Need

  • Breadboard for prototyping
  • Light Emitting Diodes (LEDs)
  • 220Ω Resistor
  • Jumper Wires
  • Arduino UNO
  • Arduino Cable
  • Laptop/PC

Circuitry

  • Place the LED and resistor on the breadboard. Be careful with the polarity of LED.

 

  • Connect the positive leg of LED with the digital Pin 13 on Arduino through jumper wire.
  • Connect the other leg of LED which is of negative polarity with the resistor as shown in the image above.
  • Connect the other leg of the resistor to the GND pin on the Arduino through jumper wire.

Code

Here’s an explanation of what is happening in the code:

  • Setup(): As you know that the setup() is the preparation of code in Arduino. Before playing with logics you need to define which pin of Arduino you are using and for what purpose, whether as an input or

 

In the code above, we are using a built-in function called pinMode(). Through this function, we are telling Arduino that which pin of is being utilized and for what purpose. We are using digital pin 13 of Arduino as an output, which means that the LED will be connected to the digital pin 13.

Syntax of pinMode:

pinMode(Pin Number, Mode: output or input);

 

  • Loop(): In this set of code, we are telling the Arduino to:

 

Turn the LED on

Wait for a second

Turn the LED off

Wait for a second

To achieve the functionality of blink, we are using digitalWrite() function and delay() function.

digitalWrite function– sets the value of digital pin either HIGH, which means powering up, or LOW, which means zero voltage. When you are using a pin as an output, you can command it to be HIGH or LOW.

Syntax of digitalWrite:

digitalWrite(Pin Number, high or low);

delay function– instructs the Arduino to pause the program on this line for time in milliseconds. In our code we are instructing the Arduino to hold the HIGH state, which in result turn on the LED, for a second and then hold the LOW state, which in result turn off the LED, for a second. All this is happening in the loop, so it will keep repeating itself.

Syntax of delay:

delay(time in milliseconds);

What You Should See?

You should see your LED blink on and off. If it isn’t, make sure you have assembled the circuit correctly and verified and uploaded the code to your board.

Leave a Reply

Your email address will not be published. Required fields are marked *