You are on page 1of 17

INTRODUCTION TO ARDUINO

What is Arduino?
Arduino is an open-source hardware and software company, project, and user
community that designs and manufactures single-board microcontrollers and
microcontroller kits for building digital devices. With this microcontroller, you can make
various digital device with various function you want.

Figure 1. Arduino Boards


In this module, there is some activity you will do. You will learn how to operate
an Arduino by practicing some sensors and modules with it.

Materials and Tools


1. Arduino Uno R3 x 1
2. LCD I2C module x 1
3. Buzzer x 1
4. HC-SR04 Ultrasonic Sensor x 1
5. Male to Female Jumper x 4
6. Arduino IDE
7. LiquidCrystal I2C library
8. NewPing library

1
Preparation

Before start to practice, you should prepare some things to get our IDE ready.
You need to install some drivers and libraries for our practice.

Installing CH340 Driver


1. Go to https://sparks.gogo.co.nz/ch340.html
2. Download the CH340 driver
3. Unzip and install it!

Installing Arduino Libraries


1. In the menu bar, open Sketch > Include Library > Manage Libraries…

Figure 2. Manage Libraries Menu


2. Search for NewPing and LiquidCrystal I2C

Figure 3. Arduino Library Manager


3. Install the two libraries shown in Fig. 3.

2
Act. 1: Arduino to LCD Screen

What do you know about LCD? What is it stands for?

LCD (Liquid Crystal Display) is a type of flat panel display which uses liquid
crystals in its primary form of operation. LEDs have a large and varying set of use
cases for consumers and businesses, as they can be commonly found in
smartphones, televisions, computer monitors and instrument panels.

Practice

In this activity, you will practice how to print some text into the LCD module and
run it with some code. You can set your Arduino and LCD according to the scheme in
Figure 4.

Figure 4. Arduino to LCD I2C Scheme

3
Write the code below to your Arduino IDE to run your Arduino device.

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27, 16 column
and 2 row display

void setup()
{
lcd.init(); // initialize the LCD

// Print a message to the LCD.


lcd.setCursor(0,0); // Set start print position (column, row)
lcd.print("This"); // Write a text to the LCD
lcd.setCursor(0,1);
lcd.print("is an LCD");
}
...

To connect your Arduino Board, plug-in to the USB port the in the menu bar
select Tools > Port and select the port available in your PC. After the board

connected, verify and upload you code to the board. Now you can see your
LCD working.

Try to change the value of lcd.setCursor() function, and see what will
happen.

Add this code and see what again will happen.

void loop()
{
delay(500);
lcd.scrollDisplayLeft();
}
The LiquidCrystal_I2C library have various function you can use. If you want to
explore the function, visit liquidcrystal Documentation.

4
Write the result of your practice here!

5
Act. 2: Arduino with Ultrasonic Sensor

Is ultrasonic sensor equal to sonar? How does it work?

Ultrasonic sensors use high frequency sound waves, and calculate the time
interval between generating and receiving the echo. They are used to detect the
presence of a target, or measure the distance to the target.

Sonar stands for SOund Navigation And Ranging. The acoustic frequency used
does not have to be ultrasonic, and can include all sound frequencies, including
infrasonic. Sonar systems may involve multiple sound transmitters, and sensors, and
may involve more complex data processing.

Ultrasonic sensors work by sending out a sound wave at a frequency above the
range of human hearing. The transducer of the sensor acts as a microphone to receive
and send the ultrasonic sound.

Practice

This time, we will learn to run an ultrasonic sensor with Arduino. Try to
connect the sensor to Arduino with the jumpers following the scheme below.

Figure 5. Arduino to HR-SC04 Ultrasonic Sensor Scheme

6
After you connect the sensor, write the code below and upload it to your
Arduino board. See what’s happened.
#include <NewPing.h>

//Ultrasonic sensor pins


#define TRIGGER_PIN 6 //Input
#define ECHO_PIN 5 //Output

NewPing ultSonic(TRIGGER_PIN, ECHO_PIN);

void setup()
{
Serial.begin(9600); //Set data rates in bit per second (bps)
}

void loop()
{
long int distance = ultSonic.ping_cm(); //get sensor output in cm
Serial.println(distance); // Print result
delay(200); //delay 200ms
}

Figure 6. Tools Menu

To see how the sensor work, go to menu bar Tools > Serial Plotter, then
a plot graph will appear. Put your hand in front of the sensor, and move your hand far
and close. how does the graph change? What happened?

Try to change the ultSonic.ping_cm() function with ultSonic.ping_cm() function.


What will happen?

You can get another type of output from the ultrasonic sensor with the NewPing
library. You can visit NewPing Arduino Library for Arduino for further information.

7
Write the result of your practice here

8
Act. 3: Arduino with Buzzer

What is Buzzer? Where can you find it in your daily life?

Piezo buzzer is a type of electronic device that’s used to produce a tone, alarm,
or sound. This device changes the electronic pulse to make a sound. It’s lightweight
with simple construction, and it’s typically a low-cost product. Piezo buzzers are often
used in alarms, warning devices, computer devices, telephones, and toys or games.

Practice

In this practice, we will try a quite simple project. We will use the buzzer module
to make a sound by using Arduino. Try to connect your buzzer to the Arduino board
following this scheme.

Figure 7. Arduino to Buzzer

With the code below you can run the buzzer with Arduino. Can you explain how
this code working?

9
#define BUZZER_PIN 7

void setup() {}

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

Try to change the delay, what will happen?

The buzzer also can use the tone() function to make a sound. If you want to
know how to use it, visit the documentation.

Write the result of your practice here!

10
Challenge

Did you know morse? How to use it?

Morse code is a method used in telecommunication to encode text characters


as standardized sequences of two different signal durations, called dots and dashes,
or dits and dahs. Morse code is named after Samuel Morse, one of the inventors of
the telegraph.

The inability of the message system in that time to give him news faster, he
started devising a plan to create a new way of fast long-distance communication. And
finally morse was born.

Figure 8. Morse Key (from 1900)

11
Figure 9. Chart of the Morse code 26 letters and 10 numerals

There is a challenge for you. Try to make a morse code using the buzzer. Try
to make out a word within 5 and 7 letters with the morse code. You can modify the
code you write before, to run the buzzer. You should follow the rules below to make
your morse code.

Rules

1. Ring the buzzer for 500ms to represent dot.


2. Ring the buzzer for 1500ms to represent dash.
3. Use 500ms delay between the symbols.

12
Mission Impossible

1. Make 2 different codes that contain a secret message with 5 to 7 letters of an


English word.
2. You can play you secret message 3 times with a delay of 10 seconds between
the plays.
3. Your friends will hear your secret code.
4. If your friend is correct, he/she will get a 100 score.

Draw your design or put a photo of your device here!

13
Write you code or put a photo of you code here!

Were there any difficulties encountered during development? What’s your


solution?

14
Sources

Figure 1. https://dev.to/anou1234/arduino-and-its-types-1lik
Figure 2. Personal documentation
Figure 3. Personal documentation
Figure 4. Personal documentation. https://wokwi.com/projects/326902301745742419
Figure 5. Personal documentation. https://wokwi.com/projects/326902301745742419
Figure 6. Personal documentation
Figure 7. Personal documentation. https://wokwi.com/projects/326902301745742419
Figure 8. https://en.wikipedia.org/wiki/Morse_code#/media/File:Morsetaste.jpg
Figure 9.
https://en.wikipedia.org/wiki/Morse_code#/media/File:International_Morse_C
ode.svg

15
References

PIEZO BUZZERS. https://www.americanpiezo.com/standard-products/buzzers.html


LCD (Liquid Crystal Display). https://whatis.techtarget.com/definition/LCD-liquid-
crystal-display
liquidcrystal Documentation.
https://readthedocs.org/projects/arduinoliquidcrystal/downloads/pdf/latest/

Morse code. https://en.wikipedia.org/wiki/Morse_code

Tag: ultrasound vs sonar. https://robotics.meta.stackexchange.com/questions/53/tag-


ultrasound-vs-sonar
tone(). https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/
Understanding How Ultrasonic Sensors Work.
https://www.maxbotix.com/articles/how-ultrasonic-sensors-work.htm

16

You might also like