Professional Documents
Culture Documents
1
Setting up and Programming Controllers
Course Code: ECE 018 Program:
Course Title: Microprocessor and Microcontroller Date Performed:
Systems and
Section: Design
ECE32S1 MarchSubmitted:
Date 4, 2021
Name/s: Arroyo, Rainier , March 3, 2021
Instructor:
Camacho, Albert
Faminiano, Emiel Renz
Viduya, Tan hay
1. Objective:
This activity aims to demonstrate the concept of programming a
microprocessor-based system. Another aim of this activity is to introduce
procedures in testing and identification of errors in a program.
2. Intended Learning Outcomes (ILOs):
After completion of this activity the students should be able to:
2.1 Write a functional program for a microprocessor-based system
2.2 Compile and Upload a processor source code
2.3 Identify errors and Debug issues in a source code for LED
control.
3. Discussion:
In essence, the word programming means giving a mechanism the
directions to accomplish a task. If you are like most people, you’ve already
programmed several mechanisms, such as your digital video recorder
(DVR), cell phone, or coffee maker. Like these devices, a computer also is
a mechanism that can be programmed. The directions (typically called
instructions) given to a computer are called computer programs or,
more simply, programs.
2. Test the function of each digital pin by turning ON all the LED’s in the
system. Write the program in the Results section.
3. Write a flowchart and program that controls the activity of LED
bulbs. The program should be able to perform the following, separately:
a. Turn on only the bits at the ODD position.
void setup()
{
for (int x = 1; x < 8; x++)
pinMode(x, OUTPUT);
}
void loop()
{
for (int y = 1; y < 8; y++)
{
digitalWrite(y, HIGH);
}
}
Program 3A
int ledpin=8;
void setup() {
for (int i=1;i<=ledpin;i++)
{
if (i%2==0)
{
pinMode(i, OUTPUT);
}
}
}
void loop()
{
for (int i=1;i<=ledpin;i++)
{
if (i%2==0)
{
digitalWrite(i, HIGH);
}
}
}
Program 3B
int ledpin=8;
void setup()
{
for (int i=1;i<=ledpin;i++)
{ pinMode(i, OUTPUT);
}
}
void loop()
{
for (int i=1;i<=ledpin;i++)
{ digitalWrite(i, HIGH);
delay(500); digitalWrite(i, LOW);
}
}
Flowchart 3A
Program 3B
int ledpin=8;
void setup()
{
for (int i=1;i<=ledpin;i++)
{ pinMode(i, OUTPUT);
}
}
void loop()
{
for (int i=1;i<=ledpin;i++)
{ digitalWrite(i, HIGH);
delay(500); digitalWrite(i, LOW);
}
}
Flowchart 3B
Program 3C
int ledpin = 8; void setup()
{
for (int i=1;i<=ledpin;i++) { pinMode(i, OUTPUT);
}
}
void loop()
{
for (int i=1;i<=ledpin;i++) { if(i%2==0){ digitalWrite(i,LOW);
}
else { digitalWrite(i,HIGH);
}}
delay(100); for (int i=1;i<=ledpin;i++) { if(i%2==0)
{ digitalWrite(i,HIGH);
}
else { digitalWrite(i,LOW);
}
}
delay(100);
}
Flowchart 3C
Test Results
when it is on.
The current, on
the other hand, is
2.97mA
when it’s HIGH and
0A when it’s LOW.
8 4.85 V 0V The voltage of
the LED
connected to pin
8 is 0V when it is
off and 4.85V
when it is on.
The current, on
the other hand, is
2.97mA
when it’s HIGH and
0A when it’s LOW.
5 4.85 V 0V The voltage of
the LED
connected to pin
5 is 0V when it is
off and 4.85V
when it is on.
The current, on
the other hand,
is 2.97mA
when it’s HIGH
and 0A when it’s
6 4.85 V 0V The voltage of
the LED
connected to pin
6 is 0V when it is
off and 4.85V
when it is on.
The current, on
the other hand,
is 2.97mA
when it’s HIGH
and 0A when it’s
7 4.85 V 0V The voltage of
the LED
connected to pin
7 is 0V when it is
off and 4.85V
when it is on.
The current, on
the other hand,
is 2.97mA
when it’s HIGH
and 0A when it’s
8 4.85 V 0V The voltage of
the LED
connected to pin
8 is 0V when it is
off and 4.85V
when it is on.
The current, on
the other hand,
is 2.97mA
when it’s HIGH
and 0A when it’s
LOW.
Errors Detected
Error Solution
7. Observations
In this laboratory activity, We used a microcontroller board Arduino Uno, the first step is to set up the coding
software settings and power the Arduino board using the USB cord connected to the USB port of the computer. We
don’t familiar with Arduino coding that’s why upon doing the activity, we encounter the problem of blinking two led's
one at a time. The two leds have a delay in interchange. the first step is to set up the coding software settings and power
the Arduino board using the USB cord connected to the USB port of the computer.
8. Conclusions
We learned how to use Tinkercad in creating and simulating Arduino uno
projects. We enjoyed creating circuit diagrams and we hope to be able to use
our learnings in this activity in the preceding laboratories.
9. Supplementary Activity
Modify code 3B such that it is able to reverse its running light direction
when it light ups the last LED in its sequence, and then it will repeat itself.
The running light should run from pin 0 to pin 13 with a delay of half a
second per LED.
Circuit Diagram:
Program:
int ledpin = 13;
void setup()
{
for (int i=0;i<=ledpin;i++)
{ pinMode(i, OUTPUT);
}
}
void loop()
{
for (int i=0;i<=ledpin;i++) {
digitalWrite(i, HIGH);
delay(500);
digitalWrite(i, LOW);
}
for (int i=ledpin;i>=0;i--) {
digitalWrite(i, HIGH);
delay(500);
digitalWrite(i, LOW);
10. Assessment (Rubric for Laboratory Performance):