LAB ACTIVITY 1output Instruction

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

CPET11L-M - Microprocessor and Microcontroller Systems, Lab

EXPERIMENT NO.1
THE OUTPUT INSTRUCTION

OBJECTIVES
This exercise aims to further expand the student’s knowledge with the basic input/output
operation of the Arduino Uno board, and Integrated Development Environment (IDE) by
developing the program learned for enabling an LED to blink. In the end of this exercise,
by also introducing an external input (a tact switch or pushbutton), the student should have
learned how to program to read inputs and to produce outputs in response to that input.

EQUIPMENTS

Software:
 Tinker CAD

BACKGROUND
The Arduino Uno belongs to a class of 8 bit microcontrollers of RISC
architecture. It has ROM, RAM, EEPROM, Flash memory and two ports namely PORTC
which has 6 pins (PC0PC5), PORTB has 7 pins (PB0PB6) and PORTD has 8 pins
(PD0PD7). These ports are configurable as input or output which means there are 21
input/output ports. They are used to interface to different electronic devices such as
LEDs, switches, motors, sensors, LCDs, and keypads.

.
LEDs with current limiting resistors are connected to microcontroller in two ways.
One is to switch them on with logic zero, and the other using logic one. The value of

Page 1 of 4
Prepared By Jonel R Macalisang
resistor is determined by the amount of current that can flow to the LED. The maximum
current flow through the LED is set by the manufacturer.

PROCEDURE
1. Set up the Software.
 Go to Tinkercad.com website.
 Create your own account make sure you have the CLASS CODE for your class
 Choose circuit

Exercises

1. Do this application that runs to turn on/off an LED. Most Arduino boards have a built-in
LED which is attached on digital pin 13.

Code:

Page 2 of 4
Prepared By Jonel R Macalisang
2. Using tact switch

Code:
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:


int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:


if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

Results and Discussion of Method of Exercises (Individual)


(Screenshot, Code and Discussion, follow the guidelines below.)

Include relevant schematic diagrams, charts, visualizations, code snippets, and program outputs for each required
problem or task. Please provide insights, commentaries, or explanations regarding the data. If an explanation requires the support of

Page 3 of 4
Prepared By Jonel R Macalisang
literature such as academic journals, books, magazines, reports, or web articles please cite and reference them using the IEEE
format.
Please take note of the styles on the style ribbon as these would serve as the style format of this laboratory report. The
body style is Times New Roman size 12, line spacing: 1.5. Body text should be in Justified alignment, while captions should be center-
aligned. Images should be readable and include captions. Please refer to the sample below:

If an image is taken from another literature or intellectual property, please cite them accordingly in the caption. Always
keep in mind the Honor Code [1] of our course to prevent failure due to academic dishonesty.

Supplemental Activities (By Group)


Create a program that will have a dancing LED using a tact switch and provide the
following:
 Your program in tinkercad.
 Flowchart
 Block Diagram
 Schematic Diagram
 Discussion of the Supplementary activities.

Instruction:
Modify the existing code so that instead of only 1 pin, 4 pins are configured to accommodate the 4 LEDs.
Note that you have two main functions so choose wisely where you put the initialization and working
program. Add another configuration for a pin to be connected to the tact/toggle switch. 2. Create the part
of the program that will read the switch’s state. Be sure to understand which nodes of the tact/toggle
switch are already shorted and not. 3. Make the program that would perform the dancing LED’s when the
program recognizes the button press. The program must not execute the light effect until the user releases
the button. The dancing LED is composed of 4 LED’s that will light up 1 at a time starting from LED1 to
LED4 and afterwards from LED4 back to LED1 Repeatedly. Code the program efficiently by using looping
functions

Result and Discussion for Supplementary Activities: (By Group)


(Screenshot, Code and Discussion, Put the name of all member, Provide a 10 slide PPT)
 Your program in tinkercad.
 Flowchart
 Block Diagram
 Schematic Diagram

Page 4 of 4
Prepared By Jonel R Macalisang

You might also like