Your First Arduino Program.

image

This is the simplest code when coding with an Arduino. It has an internal LED which is connected on pin 13, and is always configured by default; it blinks at an interval of 1 second; this is basically a short code ‘telling’ the LED to light for 1000ms(micro-seconds) then turn off for another 1000ms; it is defined by a loop function which keeps the LED turning on and off thus simulating the  ‘Blinking’ effect.

Hardware Required

  • Arduino Uno
  • LED
  • 220 ohm resistor(optional)

Assembly.

The long leg of the led(which is the anode) is connected to a 220 ohm resistor which is connected into digital pin 13 while the short leg of the led (which is the Cathode) is connected to the ground (GND).

An assembly of the project.
image

Code.

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

pinMode(13, OUTPUT);

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

digitalWrite(13, HIGH);

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

digitalWrite(13, LOW);

That takes pin 13 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.


 

To get your hands on an Arduino Board and Various Project Components just contact us

Phone Number : +2547-16806025

Email                  : brainschild.bc@gmail.com


 

A short example of the code:

 [get code]

For More information visit www.arduino.cc

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s