Fundamentals of Arduino A Guide To Arduino For Beginners: I. Objectives
Fundamentals of Arduino A Guide To Arduino For Beginners: I. Objectives
Fundamentals of Arduino A Guide To Arduino For Beginners: I. Objectives
_______________________________ _______________________________
Name Course & Year
_______________________________ _______________________________
Instructor Date
I. OBJECTIVES
1. To be able to identify the hardware parts of Arduino Uno
2. To be able to familiar with the Arduino programming environment
3. To be able to know the programming structure of Arduino and the basic commands
III. DISCUSSION
Arduino is an open source physical computing platform based on simple input / output
(I/O) board and a development environment that implements the Processing Language. Arduino
can be used to develop stand-alone interactive objects or can be connected to software on your
computer. The following are the advantages of Arduino:
1. Inexpensive
2. Cross-platform
3. Simple, clear programming environment
4. Open source and extensible software
5. Open source and extensible hardware
Below are the various types of Arduino board:
Arduino Integrated Development Environment (or Arduino Software IDE) contains a text
editor for writing code, a message area, a text console, a toolbar with buttons for common functions
and a series of menus. It connects to the Arduino hardware to upload programs and communicate
with them. Below is the screenshot of the environment of Arduino Software IDE.
Writing Sketches
Programs written using
Arduino Software IDE are called
sketches. These sketches are written in
the text editor and are saved with the
file extension .ino. The message area
gives feedback while saving and
exporting and also display errors. The
console displays text output by the
Arduino Software, including complete
error messages and other information.
The bottom righthand corner of the
window displays the configured board
and serial port. The toolbar buttons
allow you to verify and upload
programs, create, open, and save
sketches, and open the serial monitor.
void loop() { }
This function is run after setup has finished. After it has run once it will be run again, and again,
until power is removed. This function is used for the operation of the Arduino.
void setup()
{
statements;
}
void loop()
{
statements;
}
user-defined functions
Common terms
“sketch” – a program you write to run on an Arduino board
“pin” – an input or output connected to input / output device
“digital” – values either HIGH or LOW
“analog” – for PWM output, value ranges from 0 up to 255
Basic Commands
1. pinMode()
- Configures the specified pin to behave either as an input or an output
Syntax: pinMode(pinNumber,mode)
where:
pinNumber – the number of digital pin
mode – INPUT, OUTPUT, or INPUT_PULLUP
Example: pinMode(13,OUTPUT);
2. digitalWrite()
- Write a HIGH or a LOW value to a digital pin
Syntax: digitalWrite(pinNumber, value)
where:
pinNumber – the number of digital pin
value – HIGH or LOW
Example: digitalWrite(13,HIGH);
IV. PROCEDURE
A. Blinking LED with Arduino Uno
1. Open the Arduino software IDE
2. Type the given program below to the text editor of the Arduino software IDE
/*
* Sample No. 1: Blinking LED
*/
void setup()
{
// digital pin 2 ~ 5 = used as output pins
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
}
void loop()
{
// LEDs 1 ~ 4 = ON
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
delay(1000); // pause (1000ms = 1 second)
// LEDs 1 ~ 4 = OFF
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
delay(1000); // pause (1000ms = 1 second)
}
3. Set the board in the Arduino software IDE – used Arduino Uno
4. Save the program – File Name: Exercise1Sample1LastName
5. Compile the program by clicking the “Verify” button
6. Connect the Arduino Uno to the computer using USB cable
7. Set the port in the Arduino software IDE (Make sure that the set port match COM Port number
seen in the device manager)
8. Upload the program by clicking the “Upload” button
9. Remove the USB cable to the computer
10. Connect the circuit shown below
11. Connect the USB cable to the computer and observe the output
9. Double click the Arduino Uno (window will appear) and load the hex file
2. Identify the parts of the Arduino software IDE based on the figure below.
1. ______________________ 7. ________________________
2. ______________________ 8. ________________________
3. ______________________ 9. ________________________
Arduino Switching
Relay 12-V Lamp
Uno Circuit