PROJECTS CODE

Download The Arduino ide Software

Try it for free . No registeration needed.

Get Code

Arduni Uno Code for Beginner

This example shows the simplest thing you can do with an Arduino to see physical output: it blinks the on-board LED.

Hardware Required

  • Arduino Board

optional

  • LED
  • 220 ohm resistor

Circuit

This example uses the built-in LED that most Arduino boards have. This LED is connected to a digital pin and its number may vary from board type to board type. To make your life easier, we have a constant that is specified in every board descriptor file. This constant is LED_BUILTIN and allows you to control the built-in LED easily. Here is the correspondence between the constant and the digital pin.

  • D13 – 101
  • D13 – Due
  • D1 – Gemma
  • D13 – Intel Edison
  • D13 – Intel Galileo Gen2
  • D13 – Leonardo and Micro
  • D13 – LilyPad
  • D13 – LilyPad USB
  • D13 – MEGA2560
  • D13 – Mini
  • D6 – MKR1000
  • D13 – Nano
  • D13 – Pro
  • D13 – Pro Mini
  • D13 – UNO
  • D13 – Yún
  • D13 – Zero

If you want to light an external LED with this sketch, you need to build this circuit, where you connect one end of the resistor to the digital pin correspondent to the LED_BUILTIN constant. 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 the diagram below we show an UNO board that has D13 as the LED_BUILTIN value.

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

circuit

Schematic

schematic

 

Code

After you build the circuit plug your Arduino board into your computer, start the Arduino Software (IDE) and enter the code below. You may also load it from the menu File/Examples/01.Basics/Blink . The first thing you do is to initialize LED_BUILTIN pin as an output pin with the line

pinMode(LED_BUILTIN, OUTPUT);

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

digitalWrite(LED_BUILTIN, 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(LED_BUILTIN, LOW);

That takes the LED_BUILTIN pin back to 0 volts, and turns the LED off. In between the on and the off, you want enough time for a person to see the change, so the

delay()

commands tell the board to do nothing for 1000 milliseconds, or one second. When you use the

delay()

command, nothing else happens for that amount of time. Once you’ve understood the basic examples, check out the BlinkWithoutDelay example to learn how to create a delay while doing other things.

Once you’ve understood this example, check out the DigitalReadSerial example to learn how read a switch connected to the board.

 

I am item content. Click edit button to change this text. Lorem ipsum dolor sit amet, adipiscing elit. Ut elit tellus, luctus nec mattis, pulvinar dapibus leo.

I am item content. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus ullamcorper mattis, pulvinar dapibus leo.

I am item content. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut luctus nec ullamcorper mattis, pulvinar dapibus leo.

I am item content. Click edit button to change this text. Lorem ipsum dolor sit amet, adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

You can build these Projects with the help of components

Arduino Uno For Beginners Kit
Arduino Uno For Beginners Kit

Package Includes

1 × UNO R3 CH340
1× USB CABLE.
1 × breadboard.
5 × LED lights red.
5× LED lights green.
5.× LED lights yellow.
5.× LED lights blue.
5 × Resistor 220 ohm.
5 × Resistor 1K.
5× Resistor 10K.
5 × Resistor 1M.
5 × Resistor 4.7K.
5 × Resistor 560E.
2 × 5mm 5528 LDR Photoresistor.
1 × piezo buzzer.
1 × Servo Motor.
2 × 7 Segment.
1 × Relay 5v.
40×1 Pin Header.
1× LCD Display.
5 × Buttons.
10 pin Male to Female Dupont Cable.
10 pin Male to Male Dupont Cable.
10 pin Female to Female Dupont Cable.

Contact Form Demo

Contact Us