0% found this document useful (0 votes)
25 views23 pages

IOT phần 1

This document provides an introduction to Arduino and Arduino programming. It discusses installing the Arduino development environment and configuring Arduino programs. It then describes several tasks for blinking LEDs using an Arduino board and breadboard in different configurations like serial, parallel and sequencing.

Uploaded by

hophucquan4630
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views23 pages

IOT phần 1

This document provides an introduction to Arduino and Arduino programming. It discusses installing the Arduino development environment and configuring Arduino programs. It then describes several tasks for blinking LEDs using an Arduino board and breadboard in different configurations like serial, parallel and sequencing.

Uploaded by

hophucquan4630
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

HO CHI MINH CITY UNIVERSITY OF INDUSTRY

AND TRADE

LAP 1: INTRODUCTION TO ARDUINO & ARDUINO


PROGRAMMING

HO CHI MINH City, month 3 year 2024


Group members list
1 Hoàng Trung Dũng 2032220687
2 Nguyễn Hoàng Tuấn Dũng 2032220688
3 Trịnh Quang Hùng 2032221567
4 Lương Minh Kha 2032221963
5 Hồ Phúc Quân 2032223946
TABLE OF CONTENT

LAP 1: INTRODUCTION TO ARDUINO & ARDUINO


PROGRAMMING
ACKNOWLEDGEMENT...........................................................................................................................1
CHAPTER 1: INTRODUCTION TO ARDUINO............................................................................................2
I. INTRODUCTION TO ARDUINO....................................................................................................2
II. INSTALLING ARDUINO DEVELOPMENT ENVIRONMENT.............................................................3
III. CONFIGURATION OF THE ARDUINO PROGRAM.....................................................................4
CHAPTER 2: ARDUINO PROGRAMMING................................................................................................5
TASK 2.2 - LED Blink with built-in LED................................................................................................6
TASK 2.3: LED BLINK WITH BREADBOARD.........................................................................................7
TASK 2.4: LEDS IN SERIAL MODE........................................................................................................9
TASK 2.5: LEDS IN PARALLEL MODE.................................................................................................10
TASK 2.6: TURN ON/OFF LED IN SEQUENCING................................................................................11
TASK 2.7: MAKE A TRAFFIC LIGHT SYSTEM......................................................................................13
LIST OF FIGURE
Figure 1 PROTEUS TASK 2.2..............................................................................................................6
Figure 2 HARDWARE TASK 2.2........................................................................................................6
Figure 3 PROTEUS TASK 2.3..............................................................................................................7
Figure 4 HARDWARE TASK 2.3 PART 1...........................................................................................7
Figure 5 HARDWARE TASK 2.3 PART 2...........................................................................................8
Figure 6 PROTEUS TASK 2.4..............................................................................................................9
Figure 7 PROTEUS TASK 2.5............................................................................................................10
Figure 8 HARDWARE TASK 2.5.......................................................................................................10
Figure 9 PROTEUS TASK 2.6............................................................................................................11
Figure 10 HARDWARE TASK 2.6 PART 1.......................................................................................11
Figure 11 HARDWARE TASK 2.6 PART 2.......................................................................................12
Figure 12 HARDWARE TASK 2.6 PART 3.......................................................................................12
Figure 13 PROTEUS TASK 2.7..........................................................................................................13
Figure 14 HARDWARE TASK 2.7 PART 1.......................................................................................13
Figure 15 HARDWARE TASK 2.7 PART 2.......................................................................................14
Figure 16 HARDWARE TASK 2.7 PART 3.......................................................................................14
ACKNOWLEDGEMENT
I would like to thank the following people, without whom I would not have
been able to complete this research, and without whom I would not have made it
through my masters degree!
I hereby declare that this thesis was carried out by myself under the guidance
and supervision of and that the work contained and the results in it are true by author
and have not violated research ethics. The data and figures presented in this thesis are
for analysis, comments, and evaluations from various resources by my own work and
have been duly acknowledged in the reference part.
In addition, other comments, reviews and data used by other authors, and
organizations have been acknowledged, and explicitly cited.
However, in the process of making the project due to limited specialized knowl
edge, it is inevitable that some shortcomings when presenting and evaluating the probl
em. We look forward to receiving your suggestions and assessments to make my grou
p's topic more complete. Thank you very much!
CHAPTER 1: INTRODUCTION TO ARDUINO
I. INTRODUCTION TO ARDUINO
Arduino is an open-source electronics platform based on easy-to-use hardware and
software. Arduino boards are able to read inputs - light on a sensor, a finger on a
button, or a Twitter message - and turn it into an output - activating a motor, turning
on an LED, publishing something online. You can tell your board what to do by
sending a set of instructions to the microcontroller on the board. To do so you use the
Arduino programming language (based on Wiring), and the Arduino Software (IDE),
based on Processing.
Over the years Arduino has been the brain of thousands of projects, from everyday
objects to complex scientific instruments. A worldwide community of makers -
students, hobbyists, artists, programmers, and professionals - has gathered around this
open-source platform, their contributions have added up to an incredible amount of
accessible knowledge that can be of great help to novices and experts alike.
Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast
prototyping, aimed at students without a background in electronics and programming.
As soon as it reached a wider community, the Arduino board started changing to adapt
to new needs and challenges, differentiating its offer from simple 8-bit boards to
products for IoT applications, wearable, 3D printing, and embedded environments.
II. INSTALLING ARDUINO DEVELOPMENT ENVIRONMENT
In order to write a code, the text/code editor is required. A compiler is then required to
translate the written code into binary files or machine code, which
the microcontroller then can understand. Programming software is also required in
order to load the firmware files to the microcontroller.
An Integrated Development Environment, which can be described simply as Arduino
Software, is what we refer to when we are combining all of these functionalities with
some extras like console support, debugging support, etc.
The development IDE that is suited for Arduino boards is known by the moniker
Arduino IDE. It has a compiler, code editor, serial console, programmer, serial plotter,
as well as many other capabilities that are fully featured. Also, it is straightforward
and simple to use.
The Arduino IDE can be described as a cross-platform and can function on Microsoft,
Linux, and Windows operating systems. Additionally, you may program these boards
utilizing the C/C++-derived Arduino Language and Arduino IDE.
Writing code and uploading it onto the circuit board while offline is simple with
Arduino Software. Every Arduino board is compatible with this software.
Arduino IDE is now available in two different versions: 1.x.x and 2.x. IDE 2.x is a
brand-new major update that outperforms IDE 1.x.x in terms of speed and power. It
also has more sophisticated capabilities to aid users in their debugging and coding in
addition to more contemporary editor and a responsive user interface.
The installation of the Arduino IDE is rather simple. To obtain the most recent edition
of the Arduino IDE, visit Arduino IDE. For several operating systems, including
Windows, Linux, and Mac, there are numerous versions available.
Additionally, there are now two versions of the IDE: 1.x as well as 2.x. In this tutorial,
we’ll focus on Classic 1.X version. In essence, both offer nearly identical functionality
having its different GUI and a few extra capabilities, including automatic code
completion.
 Click the aforementioned link to download any installer for the OS system.
 Open that .exe file after the download is complete.
 Click “Next” to proceed after accepting the license agreement and deciding whether
or not to install the IDE for all users.
 Click “Install” after deciding whether you wish to alter the default installation
location for the IDE or leave it alone.
 After the installer has completed installing, click “Close.”
III. CONFIGURATION OF THE ARDUINO PROGRAM
The setup() function is called when a sketch starts. Use it to initialize variables, pin
modes, start using libraries, etc. The setup() function will only run once, after each
powerup or reset of the Arduino board.
Arduino programs can be divided in three main parts: Structure, Values (variables
and constants), and Functions. In this tutorial, we will learn about the Arduino
software program, step by step, and how we can write the program without any syntax
or compilation error.
CHAPTER 2: ARDUINO PROGRAMMING

# Device Quantity
1 Arduino Board 1
2 BreadBoard 1
3 LED 5
4 Resistor 220 Ω 5
5 USB connector 1
6 Jumper Wires 10
7 Battery 9V (optional) 1
8 VOM Multimeter 1
Table 1 LAB EQUIPMENT
TASK 2.2 - LED Blink with built-in LED
Procedure
1. Use built-in LED (LED 13) for testing

Figure 1 PROTEUS TASK 2.2


2. Write the code with Arduino IDE:
- LED works in duty cycle: Turn on in 1s and off in 1s

Figure 2 HARDWARE TASK 2.2


- Change the duty cycle (on/off interval) and see how it works
In 1 cycle, time On is 1s off is 2s, output 5v in 1s and 0v in 2s
TASK 2.3: LED BLINK WITH BREADBOARD
Procedure
1. Use Fritzing tool to draw a circuit diagram as shown in Figure 2
2. Connect LED, and resistor 100 Ω via breadboard and Pin 10 on Arduino (figure 2)

Figure 3 PROTEUS TASK 2.3


3. Write the code with Arduino IDE:
- LED works in duty cycle: Turn on in 1s and off in 1s

Figure 4 HARDWARE TASK 2.3 PART 1


- Print message in Serial monitor:
+ Print “LED on” in Serial monitor when turning LED on
+ Print “LED off” in Serial monitor when turning LED off

Figure 5 HARDWARE TASK 2.3 PART 2


TASK 2.4: LEDS IN SERIAL MODE
Procedure
1. Connect 3 LEDs, and resistor 220 Ω via breadboard in serial connection and Pin 10
on Arduino

Figure 6 PROTEUS TASK 2.4


2. Write the code with Arduino IDE:
- LED works in duty cycle: Turn on in 1s and off in 1s
- Print message in Serial monitor:
+ Print “3 LED in serial mode on” in Serial monitor when turning LED on
+ Print “3 LED in serial mode off” in Serial monitor when turning LED off
TASK 2.5: LEDS IN PARALLEL MODE
Procedure
1. Connect 3 LEDs, and resistor 220 Ω via breadboard in parallel mode and Pin 10 on
Arduino

Figure 7 PROTEUS TASK 2.5


2. Write the code with Arduino IDE:
- LED works in duty cycle: Turn on in 1s and off in 1s
- Print message in Serial monitor:
+ Print “3 LED in parallel mode on” in Serial monitor when LED on
+ Print “3 LED in parallel mode off” in Serial monitor when LED off
Figure 8 HARDWARE TASK 2.5
TASK 2.6: TURN ON/OFF LED IN SEQUENCING
Procedure
1. Connect 3 LEDs, and resistor 220 Ω to 3 pin (8, 9, 10) on Arduino

Figure 9 PROTEUS TASK 2.6


2. Write the code with Arduino IDE: - LED turn ON/OFF in sequencing (order 1, 2, 3,
…)
Figure 10 HARDWARE TASK 2.6 PART 1

Figure 11 HARDWARE TASK 2.6 PART 2


Figure 12 HARDWARE TASK 2.6 PART 3
TASK 2.7: MAKE A TRAFFIC LIGHT SYSTEM
Procedure
1. Use 3 LEDs (Red, green, yellow) and resistor 220 Ω to connect to 3 pin Digital I/O
on Arduino

Figure 13 PROTEUS TASK 2.7 PART 1


Figure 14 PROTEUS TASK 2.7 PART 2

Figure 15 PROTEUS TASK 2.7 PART 3


2. Make a traffic light system:

+ Green LED turn ON in 30s


+ Yellow LED on in 3s + Red LED on in 20s
+ Working continously in this cyclE

Figure 16 HARDWARE TASK 2.7 PART 1

Figure 17 HARDWARE TASK 2.7 PART 2

Figure 18 HARDWARE TASK 2.7 PART 3

You might also like