Arduino Beginners course – Lesson 1

Arduino Beginners course – Lesson 1

Starting from the beginning with the Arduino IDE and with the LCD Hello World!

Welcome to this Arduino Beginners course! This is the first lesson so we have to introduce you to the “Arduino world”!

Of course first of all we have to explain you what is Arduino, how to download the Arduino IDE and how to use it!

Let’s start!

What is an Arduino Board?

Arduino is an italian project, and it is a low cost microcontroller used to prototype and create nice projects. The most important thing is that is Open Source!

People that use very often an Arduino board are called ‘makers’. That’s because they can make wonderful projects with a simple microcontroller and some components.

Arduino is a very simple microcontroller and everyone can learn how to use it! If you will follow us, you will learn a lot of things with our tutorials!

It’s not just a board! Arduino is a big family to which belong a lot of different boards. Each board could be better then another for a particular project. We will explain this in another article.

Moreover, there are also some compatible boards that will be very helpfull for our projects.

Getting started – Download the Arduino IDE

So we want to write some code for Arduino…but how? Of course we need the Arduino IDE. You can download it here(Win, Linux, Mac OS). Install the Arduino IDE and then launch it.

To program and Arduino board you have to write the sketch in C++, but don’t worry about it, you are following this lesson to learn it, so we will explain it in each step!

You will see how easy and cool is to program and create projects with Arduino!

Now that you have started the Arduino IDE, go in Tools/Board and select your board.

What is a Library?

Libraries are very important for a maker, they make it easier to make sketches! Read the guide to libraries here, you will learn how to add a new library to the Arduino IDE with two different methods -> Libraries Guide.

First Hello World

Once you have read the Libraries Guide you are ready to go on and create your first Hello World with Arduino!

Read the Tutorial Here, in this tutorial you will make an Hello World on the Serial Monitor and you will learn how to create a New Project, compile and Upload the code to the Arduino Board. -> Hello World Tutorial

Another step, LCD

Now that you know how to make an Hello World on the Serial Monitor, let’s make an Hello World on an LCD.

Now you will learn how to use an LCD (Liquid Crystal Display) module with an Arduino board. We will use a lot of LCDs in our projects! This module is very useful and simple to use.

Schematics

That’s how to connect an LCD to an Arduino Board.

We will not use all the LCDs pins, connect the LCD as in picture.

Arduino LCD schematic

As you can see we also have to use a potentiometer. We use it to change the contrast on the LCD.

Note that this Schematic is for an Arduino Mega, but it’s the same for every Arduino board. Just connect to the same pins on your Arduino Board.

Sketch

Here we will learn how to write a sketch for using the LCD with Arduino.

First of all we need to add the Liquid Crystal Library.

We yet explained how to add a library to the Arduino IDE.

You can do that in this way: Sketch > Include Library > Liquid Crystal (follow the tutorial: How To add a Library to Arduino IDE).

The second step is to include the library to the sketch:

#include <LiquidCrystal.h>

Then we have to create an lcd object.

const int rs = 1, en = 2, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

We initialize the lcd object with the values of the Arduino Digital pins.

Then in the setup we have to initialize the interface to the LCD and specify the dimensions of the display using the begin() function.

Moreover there are other useful functions:

  • Using the print() function we print something on the LCD.
  • The setCursor() function: set the position at which the text have to be displayed on the LCD.
  • The blink() functiondisplay a blinking cursor and the noBlink() function for turning it off.
  • The cursor() function is used for displaying underscore cursor and the noCursor() function for turning off.
  • Using the clear() function we can clear the LCD screen.

Here is the code:

#include <LiquidCrystal.h> 

const int rs = 1, en = 2, d4 = 4, d5 = 5, d6 = 6, d7 = 7;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup()
{ 
 lcd.begin(16,2);
 lcd.print("Hello World"); // Prints "Hello World" on the LCD 
 delay(3000); // 3 seconds delay 
 lcd.setCursor(2,1); // Sets the location at which subsequent text written 
                     //  to the LCD will be displayed 
 lcd.print("LCD Tutorial"); 
}

void loop() 
{ 
}

We also used the function delay(milliseconds), it’s used to stop the Arduino execution for a time equal to the number in ( ).

For example if I write delay(1000), it will be a delay of 1 second. That’s because you have to write the amount of time in milliseconds!

Last thing before the end

We want you to learn just one last thing before the end: Statements.

Statements are the most used in sketches and they are used to make easy, clear and professional sketches!

That’s a list of statements that you have to know if you want to learn to make some codings! They are essentials! You won’t make any code without those Statements.

List of the Statements with Tutorials

That’s all for this first lesson, hope you enjoyed this Arduino Beginners Course and that you will read the other lessons!

There will be a Button to the next lesson as soon as we will publish the lesson 2!

Davide Busco

Davide Busco is an engineering student at Federico II University of Naples. He uses his passion and studies to create his projects. He loves be a maker and spread his knowledge. Moreover he has gained the second place in a national makers-tournament between Italian's Universities.

Leave a Reply

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

en_GBEnglish (UK)
it_ITItaliano en_GBEnglish (UK)
%d bloggers like this: