Vous êtes sur la page 1sur 5

EXERCISE 1 %$6,&6(5,$/+(//2:25/'

A. Objectives
x This example aims to familiarize the student with the basic operation of the
Arduino board, and Integrated Development Environment (IDE). By the end of
the exercise, the student should be able to know the basic functionalities of
the IDE.
x This exercise also aims for the student to learn how to use the serial feature of
the Arduino Board and IDE.
x This exercise will also serve as an introductory for the students on using the
serial to output symbols and texts based on a program that later will be used to
read data values from sensors. By the end of this exercise, students should be
able to output a message onto the serial monitor of the Arduino IDE.
B. Materials Needed
x 1 x Arduino board and USB cable
C. Using the Arduino IDE
1. Double-click the arduino application to open the Arduino IDE which is shown below:

Figure 1: Screenshot of the Arduino IDE. The workspace is very simple and frequently used buttons are easy to
access

2. Type the following lines of code on the front panel.

3. Press Ctrl + S or

icon on the IDE to save your sketch.

4. Click the Verify Button


to check if the sketch has no errors. At the bottom of
the screen you should see if the sketch was successfully scanned free of problems.
Moreover, the size of the sketch file is also indicated on the black screen at the
bottom to shows that it fits the flash memory of the Arduino.

5. Check if the board selected in the IDE is the one you are using, choose Arduino Duemilanove
w/ ATmega328.

1H[WPDNHVXUHWKDWWKH$UGXLQRERDUGV&20SRUWLVSURSHUO\LGHQWLILHGE\WKH
IDE. To do this, connect the board to the computer then from the IDE front panel go
to Tools > Serial Port. $OLVWRI&20VVKRXOGEHWKHUHFKRRVHWKH&20QXPEHU
associated with the microcontroller board.
1RWHWKHPLFURFRQWUROOHUERDUGV &20QRLVIRXQGQHDUWKHQDPHRIWKHGHYLFHVGULYHULQDevice
Manager

7. Upload the sketch made earlier into the board by clicking the
icon in the IDE.
The status of the upload can be found near the bottom of the program.

8. Open the Serial Monitor by clicking the


icon right of the upload icon in the IDE,
sHHLILWZRXOGRXWSXWD+HOOR:RUOGPush the reset button in the arduino board,
see what happens.
D. What to expect
You have just written a sketch that programmed the Arduino board to use the serial
monitor to allow the board and PC to communicate. The program prints an output in
the serial monitor a +HOOR:RUOGafter that the program remains idle.

E. ACTIVITY
Compile and upload the following sketch in the Arduino IDE

Sketch 2





void setup()



{





Serial.begin(9600);


}





void loop()



{





Serial.println("Hello World");
}




Sketch 3
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println("Hello World");
delay(5000);
}

Analyze/Discuss
x List the programs similarities and differences
x Analyze the three program in detail, explaining what part of the program
causes their similarities and differences
F. QUESTION
(Research the following if necessary)
1. How do you compile and upload a sketch file into the Arduino Board using the
IDE?
2. What functions are always required in a sketch?
3. How does the Arduino Board communicate with a PC?
4. What are the functions used in a serial communication for arduino?
5. What is the necessary initialization for serial communication to take place?

G. DISCUSSION AND ANSWER