You are on page 1of 9

Activity No.

1
Controlling Outputs Using a Microcontroller
Course Code: CPE014/CPE400 Program: BSCPE
Course Title: Embedded Systems Date Performed:
Section: Date Submitted:
Members: Instructor:
1. Objective(s):
This activity aims to introduce the microcontroller as an integral part of implementing Embedded Systems by demonstrating
how it is used to control electronic components.
2. Intended Learning Outcomes (ILOs):
After performing the laboratory activity, the students should be able to
 Apply C/C++ language programming in creating and manipulating the Arduino code
 Create a program that uses digital output.
 Use delay in the implementation of sequence output.
3. Discussion:
The microcontroller is used to receive input from sensors, switches, and other input components, process/store those input
data, and control outputs according to the program that is uploaded on the controller. A microcontroller has all the necessary
components to function as a computer. However, unlike a general-purpose computer, an embedded computer or
microcontroller/microprocessor is constrained in terms of size, cost, and performance as its purpose and use is for specific
applications only.

Microcontrollers can be found in almost all modern applications some but not limited to the field of Agriculture,
Communication, Electronics Tools, Entertainment, Medical Equipment, Office Equipment, Transportation, and even Space. In
this activity, you will see the capability of a microcontroller to control outputs such as LEDs, and Buzzers using an Arduino
Board. A microcontroller is an Integrated Circuit or IC that can be programmed and perform I/O control through its pins.

The Atmega328p microcontroller

Prototyping and programming with only a microcontroller can be difficult as you will need to wire other electronic components
and also wire an external programmer to upload codes to the microcontroller. As such a circuit board was developed for
prototyping with a microcontroller such as the Arduino Boards.
The Arduino UNO Board

The Arduino UNO Board is a prototyping board with a microcontroller that enables rapid prototyping by allowing easy
programming through the built-in USB port and serial programmer and the header pins that makes connecting wires and
components to the microcontroller easier. The Arduino UNO Board also comes with support for external power through the
DC power barrel jack and a built-in linear regulator.

Electronic Components
Light Emitting Diodes (LEDs) are used to emit signals in the form of light which can be used to convey
message/information. It is one of the most commonly implemented electronic components to output a simple
notification/message. It can be turned on by applying a small forward bias (voltage) across the Anode pin of the LED and
connecting the Cathode pin to ground.

The Schematic Symbol of an LED

Resistors are used to limit the flow of electricity in a circuit. They are connected to the LED in series in order to limit the flow
of current otherwise the LED would burn out and be permanently damaged. A Resistor has bands of different colors that
represent how much is its resistance value.
Band Color Value
Black 0
Brown 1
Red 2
Orange 3
Yellow 4
Green 5
Blue 6
Violet 7
Gray 8
White 9
Gold 1/10
Silver 1/100

Example, a 270Ω resistor has a first digit 2 (red), second digit 7 (violet), and a multiplier of 1 (brown). Similarly, at 1kΩ resistor
will have bands of brown, black, and red (1, 0, 00).

A Breadboard is used to temporarily connect electronic components, Integrated Circuits (ICs), and wires together to build
prototypes to be able to see what the circuit before it is fabricated onto a Printed Circuit Board (PCB).

Note:
The Orange wire
represents the
connections of the
breadboard.

Jumping wires and solid wires are used to connect the parts of a breadboard together to form a circuit. A jumping wire
usually has plastic that supports the ends of the wires while the solid wire only has both its ends exposed. The two ends of a
solid wire can be bent to act as a jumping wire.

Jumping Wires Solid Wires

4. Materials and Equipment:

Arduino UNO Board with USB Cable 3 470 Ω Resistors


Desktop Computer with Arduino IDE Solid Wires/Jumping Wires
Solderless Breadboard Multimeter
3 LEDs (Green, Orange, Red)

5. Procedure:

Blinking LEDs
1. Wire the circuit shown below (Digital Pins 3, 4, 5 are used).
Schematic Diagram
Wiring Diagram

2. On the Arduino IDE, click File then Examples then Basics, find the Blink LED or copy the program code below:

Note: BUILTIN_LED is equal to 13 (if you used the example).

3. Connect the Arduino Board to the Computer using the USB Cable, then click Upload.
4. Observe the output.
5. Modify the code by changing 13 to 3.
6. Apply C programming by assigning a variable to hold the pin number 3.

7. Modify the code and upload the modified program.


8. Modify the code so that all the LEDs would blink simultaneously.
9. Modify the delay(1000) and write your observations on the table below:

delay(value) Observation
2000
1000
500
100
10

LED control using for Loops


1. Create a new sketch and use the code below for the setup() code

2. Use the code below for the loop() code

3. Observe the output.


4. Measure the voltages of the pins when digital write is HIGH and also for the voltages of the pins when digital
write is LOW.
Pins Measured Voltages (V or mV)
HIGH LOW
3
4
5
6. Data Analysis:

8. Assessment (Rubric for Laboratory Performance):


7. Supplemental Activities
Intended Learning Unsatisfactory Satisfactory Exemplary
Tasks Score
Outcomes 1 2 3
1. CreateApply
a program
C/C++ that can make the to
Unable LEDs
applylight in an toalternate
Able mannerAble
apply C/C+ suchto as christmas
apply C/C++ lights.
2. Createlanguage
a program that can simulate a traffic light+using
C/C++ language languagethe Arduino and the three
language LEDs.
programming
3. Createprogramming in wouldprogramming
a program that make the LED in run fast
programming
in a backinand forth
in creating
manner.and
creating and creating and creating and manipulating the
manipulating
Screenshot the and output
of your codes manipulating
here: the manipulating the Arduino code without
Arduino code Arduino code Arduino code but errors
with errors
Create a program Unable to create a Able to create a Able to create a
that uses digital program that uses program that uses program that uses
output digital output digital output but digital output without
with errors errors
Use delay in the Unable to use Able to use delay in Able to use delay in the
implementation of delay in the the implementation implementation of
sequence output. implementation of of sequence output sequence output
sequence output but with errors without errors
Other comments/observation: Total Score
RATING = (total score) x 100%
9

Evaluated by: Date:

__________________

You might also like