ARDUINO LESSON 1 (EXPLAINING THE ARDUINO IDE AND BLINKING AND LED)

Hi guys, Its Hackmonstar.

Welcome to ARDUINO LESSON 1 (EXPLAINING THE ARDUINO IDE AND BLINKING AND LED)

Having known what the Arduino board and Arduino IDE are and their basic important features, we’ll dive straight into explaining in more details the Arduino IDE and we’ll also program the Arduino board to blink an LED. If this is your first time with Arduino and you don’t know what the Arduino is, I suggest you take a look my previous tutorial post on Introducing the Arduino (click here) where i gave a detailed introduction of the arduino. So at the end of this lesson, You would be able to:

  • Install the Arduino IDE(Integrated Development Environment) on your Laptop/Desktop
  • Understand how to use the Arduino IDE
  • Write your first code on the IDE
  • Program the Arduino board through the IDE

Watch this lesson’s video below to get a real life demonstration and thorough understanding of this lesson. Also click on the subscribe button to our Youtube channel to enable us continue making live video tutorials.

You can order / buy your Arduino board and other electronics component and accessories you need to build more interesting project at very cheaper rate from the DAEROBOTiCS online store by tapping or clicking here : DAEROBOTICS ONLINE SHOP and it would be delivered immediately to you anywhere around Nigeria.

Installing the Arduino IDE

As we well know, the Arduino IDE is The Arduino IDE (Integrated Development Environment) is a software which provides the environment where we can write programs and load into the Arduino board. To install the IDE head over to Arduino official Website(click here). Download the IDE according to your operating system. Then follow the steps given in the video above.

Going through the Arduino IDE

We would go through the important and usually used tools and features of the IDE. The first thing to know is that the IDE has an editor just like any other editor for example the microsoft word, word pad e.t.c. Program/code files written on the IDE are called “SKETCHES”. i’ll explain feature/tools on the IDE one after the other

  • The Editor/Whitespace
    The white space on the IDE is where you write your program/code as seen in the image below

The name of the white space current code file is specified on the tab.

  • The Tools bar
    The tools bar is just above the editor’s tabs,

Going from left to right, i’ll explain the tools on the tools bar:
Verify/compile button: This button is used to verify that the code you’ve written on the IDE is syntatically correct. When you are done writing your code, you clikc on this button to initiate the compilation process. Success and Error report of the verification/compilation process is reported in the status bar at the bottom of the Arduino. If you get an error, it means you should check the code you’ve written as there are some errors in it.
Upload button: This button is used to upload the code you’ve written on the IDE to the Arduino board. It also does the job of verification/compilation. That is when you click on this button, it runs the compilation first and if compilation is successful, it uploads the code to the board.
New button: As every editor, the new button creates a new “sketch” file
Open button: This also as every editor, is used to open an existing file from a folder.
Save button: This button is used to save codes written in the IDE.
Serial Monitor: This is located at the extreme right of the tools bar. The serial monitor is used for printing and serial debugging purpose

  • Menu bar
    The menu bar is just above the tools bar

I’ll be briefly going through the components of the menu bar:

File

Menu bar: File

New: As with every editor, the new creates a new “sketch” file
Open: This also as every editor, is used to open an existing file from a folder.
Open Recent: This is used to open files that were created or modified recently
Sketchbook: Contains recent sketches
Examples: Examples contains example projects accompanying the selected board
Close: Used to close project/ IDE
Save/Save as : Used to save created sketches or modified sketches
Preferences : Used to make specific setting to the IDE e.g font size, verbose e.t.c
Quit: To quit the IDE totally

Edit

Menu bar: Edit

Undo: Just as any editor, the Undo switches backward to previous changes made on the whitespace editor
Redo: This switches forward to previous changes made on the whitespace editor
Cut: Cuts a particular selected text on the editor
Copy: Copies a particular selected text on the editor

Sketch

Menu bar : Sketch

Verify/Compile: This is used to verify that the code you’ve written on the IDE is syntatically correct
Upload : This is used to upload the code you’ve written on the IDE to the Arduino board. It also does the job of verification/compilation. That is when you click on this, it runs the compilation first and if compilation is successful, it uploads the code to the board.
Include Library: It is used to include libraries which the current program code sketch is dependent on.

Tools

Menu bar: Tools

The Two most important items on the Menu bar: Tools are
Board : This is where you select your preferred development board. In this case we’ve chosen Arduino Uno.
Port: This is the COM PORT the Arduino board is connected to on the Laptop

Help

Menu bar: Help

You can visit the Arduino website through the help section

Writing Your First Program (Blinking an LED)

To really grab a feel of the Arduino IDE and what the Arduino board can do, you’ll be writing your first program code to blink an LED. In this project, an LED connected to the Arduino board would be blink continously with a one second (1sec) timing. i’ll now go over to explain the code by breaking it down before we put them together and upload to the Arduino board

int LED_PIN = LED_BUILTIN;

This first line of code declares the variable name “LED_PIN” and initializes it with the LED_BUILTIN. LED_BUILTIN has a value of GPIO 13(digital pin) on the Arduino UNO board.

void setup(void)
{
pinMode(LED_PIN, OUTPUT);
}

This is the setup function, any statement within it runs only once. In this case, the pinMode() is within the setup therefore it runs only once. pinMode is used to set the LED_PIN to a digital OUTPUT as explained in Introducing Arduino.

void loop(void)
{
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN,LOW);
delay(1000);
}

This is the loop function, any statement within the loop function runs over and over again repeatedly.
digitalWrite (LED_PIN,HIGH) makes the LED to turn on
delay(1000) keeps the LED on for 1 second
digitalWrite(LED_PIN, LOW) makes the LED to turn off
delay(1000) keeps the LED off for 1 second
Because all these statement are inside the loop, they run over and over again so that the LED turns on and turn off repeatedly to create the blinking effect.

Here is the code in full

int LED_PIN = LED_BUILTIN;

void setup(void)
{
  pinMode(LED_PIN, OUTPUT);
}

void loop(void)
{
  digitalWrite(LED_PIN, HIGH);
  delay(1000);
  digitalWrite(LED_PIN,LOW);
  delay(1000);
}

Uploading the Code to the Arduino

After writing the code, we’ll then upload it to the Arduino board.

  • First, you plug the board to the Laptop
Connect the Arduino to the Laptop to before clicking upload
  • Second, you check if the Arduino board and COM PORT are set under the tools in the Menu bar
Exif_JPEG_420
  • Third, you click the Upload button on the Tools bar.

Connect the circuit

Here i’ve listed the components you need to build the circuit and the link through which you can buy it and it will be delivered to your doorstep if you live within Nigeria

  1. Arduino (Buy here from the shop)
  2. Battery connector (Buy here from the shop)
  3. 9Volts Battery (Buy here from the shop)
  4. 390 ohm resistor (Buy here from the shop)
  5. Breadboard (Buy here from the shop)
  6. Jumperwires (Buy here from the shop)
  7. LED (Buy here from the shop)

Connect the circuit on a breadboard as shown in the image below

Watch the Video below to see the LED blinking while the code is running on the Arduino board.

So guys we’ve come to end of todays lesson on the Arduino. Subscribe to the DAEROBOTICS Youtube channel to get video update notification on every of our new lesson. Place your comment just below and i’ll reply when i see it. Thanks

Leave a Comment

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