BSEE 3E - Laboratory - Act#1
BSEE 3E - Laboratory - Act#1
BSEE 3E - Laboratory - Act#1
PHILIPPINES
Ayala Blvd. Ermita, Manila, 1000, Philippines
College of Engineering
Electrical Engineering Department
Laboratory Activity 1
ACEE12L-M : Microprocessor System Lab
Submitted by:
BSEE 3E-M
Esteron, Marvin Q.
Submitted to:
9. Text Console – shows the IDE status (and displays syntax errors)
10. Line Number – points the line number where syntax error occurred
after compiling.
Setting Up the Arduino Board
Board Set-Up
To power up the board and verify if it is working,
plug in the board to a computer via USB cable and
check if:
delays in
milliseconds
Comments
Additional comments can be used to
dissect the parts of the program codes.
These are ignored by the IDE during
compilation but are useful for the users.
Two forms of comments:
block comment – enclosed by / * (comments
here!) * /
// the led will turn on for .5 seconds and turns off with .5
sec delay
Activity 1.1
// C++ code
//
const int Led13_Red = 13;
void setup()
{
pinMode(Led13_Red, OUTPUT);
}
void loop()
{
digitalWrite(Led13_Red, HIGH);
delay(1500);// Wait for 1500 millisecond(s)
digitalWrite(Led13_Red, LOW);
delay(1000);// Wait for 1000 millisecond(s)
}
Activity 1.2
// C++ code
//
const int Led1_Green = 2;
void setup()
{
pinMode(Led1_Green, OUTPUT);
}
void loop()
{
digitalWrite(Led1_Green, HIGH);
delay(600);// Wait for 600 millisecond(s)
digitalWrite(Led1_Green, LOW);
delay(800);// Wait for 800 millisecond(s)
}
Activity 1.3
// C++ code
//
const int Led1_Green = 2;
const int Led2_Red = 3;
const int Led3_Blue = 4;
const int Led4_Orange = 5;
const int Led5_Yellow = 6;
const int Led6_Green = 7;
const int Led7_Red = 8;
const int Led8_Blue = 9;
void setup()
{
pinMode(Led1_Green, OUTPUT);
pinMode(Led2_Red, OUTPUT);
pinMode(Led3_Blue, OUTPUT);
pinMode(Led4_Orange, OUTPUT);
pinMode(Led5_Yellow, OUTPUT);
pinMode(Led6_Green, OUTPUT);
pinMode(Led7_Red, OUTPUT);
pinMode(Led8_Blue, OUTPUT);
void loop()
{
//All delay 1 second
//turn pin Led1_Green HIGH
digitalWrite(Led1_Green, HIGH);
digitalWrite(Led2_Red, LOW);
digitalWrite(Led3_Blue, LOW);
digitalWrite(Led4_Orange, LOW);
digitalWrite(Led5_Yellow, LOW);
digitalWrite(Led6_Green, LOW);
digitalWrite(Led7_Red, LOW);
delay(1300);// Wait for 1300 millisecond(s)
}
Activity 1.4
// C++ code
//
const int Led1_Green = 2;
const int Led2_Red = 3;
const int Led3_Blue = 4;
const int Led4_Orange = 5;
const int Led5_Yellow = 6;
const int Led6_Green = 7;
const int Led7_Red = 8;
const int Led8_Blue = 9;
const int Led9_Orange = 10;
const int Led10_Yellow = 11;
const int Led11_Green = 12;
const int Led12_Red = 13;
void setup()
{
pinMode(Led1_Green, OUTPUT);
pinMode(Led2_Red, OUTPUT);
pinMode(Led3_Blue, OUTPUT);
pinMode(Led4_Orange, OUTPUT);
pinMode(Led5_Yellow, OUTPUT);
pinMode(Led6_Green, OUTPUT);
pinMode(Led7_Red, OUTPUT);
pinMode(Led8_Blue, OUTPUT);
pinMode(Led9_Orange, OUTPUT);
pinMode(Led10_Yellow, OUTPUT);
pinMode(Led11_Green, OUTPUT);
pinMode(Led12_Red, OUTPUT);
void loop()
{
//the led will light one after the other
//All delay 0.3 second
//turn pin Led1_Green HIGH and LOW
digitalWrite(Led1_Green, HIGH);
digitalWrite(Led2_Red, LOW);
digitalWrite(Led3_Blue, LOW);
digitalWrite(Led4_Orange, LOW);
digitalWrite(Led5_Yellow, LOW);
digitalWrite(Led6_Green, LOW);
digitalWrite(Led7_Red, LOW);
digitalWrite(Led8_Blue, LOW);
digitalWrite(Led9_Orange, LOW);
digitalWrite(Led10_Yellow, LOW);
digitalWrite(Led11_Green, LOW);
digitalWrite(Led12_Red, LOW);
delay(300);// Wait for 300 millisecond(s)
}
Observation:
In Tinkercad, you can simulate a blinking LED using the built-in simulation
feature. In creating a blinking effect on the LED you will simply adjust the delay
time in the program so that you can slowdown or speed up the blinking effect of
the LED and by observing the LED in the simulation, you can confirm that the code
is working properly and that the LED is blinking according to the program.
Conclusion:
Arduino CookBook
Recipes to Begin, Expand, and Enhance
Your Projects
By Michael Margolis
Introduction to Arduino
By Alan G. Smith