IoT Bytes

Bits and Bytes of IoT

Getting Started with Arduino

Pradeep Singh | 18th Nov 2017

Arduino_Logo

1. Before you begin:

Before you begin with this article make sure you have following hardware and software pieces ready –

1.1 Hardware:

For this article, I will be using the basic Arduino Uno board that looks like this –

ArduinoUno

1.2 USB Cable:

To program Arduino board you need a “USB 2.0 A-Male to B-Male cable”. The two ends of this USB cable should look like this –

USB_A-Male_to_B-Male_cable

1.3 Arduino IDE:

Before you begin you need to install Arduino IDE on your computer. Based on the operating system installed on your computer, you can download the Arduino IDE installer from the following site –

https://www.arduino.cc/en/Main/Software

2. Connection and Settings:

2.1 Connect the USB Cable:

Connect one end of the USB cable with Arduino Uno board and the other end with the USB port of your computer. As soon as the cable is connected to the computer, a green LED (power) on the Arduino board should tun on.

2.2 Select the Board:

Open the Arduino IDE on your computer and select the Arduino Board you want to program. To select the board, go to “Tools –> Board” menu option and select the board type for example “Arduino/Genuino Uno” as shown in the following screenshot –

Board

2.3 Select the Serial Port:

After selecting the Arduino board on the Arduino IDE, now you need to select the Serial Port on your computer where your Arduino board is connected. To do this, go to “Tools –> Port” menu option and select the Arduino device from the list as shown in the following screenshot –

Serial Port

3. Blink the LED using Arduino Code/Sketch:

Now you are ready to write your first Arduino program. Arduino IDE includes many examples for the beginners to start with Arduino sketches. At this stage, I will keep it simple by using a basic LED Blinker example.

To access the examples to should go to “File –> Examples –> 01. Basics” menu option and select “Blink” example as shown in the following screenshot –

Examples

Now you should see the following Arduino sketch on the IDE window-

void setup() {
 // initialize digital pin LED_BUILTIN as an output.
 pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
 digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
 delay(1000); // wait for a second
 digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
 delay(1000); // wait for a second
}

If you notice, this example is using “LED_BUILTIN” keyword. It refers to the built-in LED that is available on your Arduino board by default. For Arduino Board, the built-in LED is connected with PIN 13 as shown in the following image –

ARDUINO_UNO_LED

Now you are ready to push/burn this LED Blinker code/sketch to your Arduino board. Click on the arrow icon (shown in the following image) on the toolbar of your Arduino IDE to push the code to Arduino Board.

PushCode

On successful code push, the built-in LED will start blinking. You can play with the “delay” values in the code and change the blink speed of this LED.


 

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: