Professional Documents
Culture Documents
LAB ACTIVITY 1output Instruction
LAB ACTIVITY 1output Instruction
LAB ACTIVITY 1output Instruction
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 (PC0PC5), PORTB has 7 pins (PB0PB6) and PORTD has 8 pins
(PD0PD7). 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
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);
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.
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
Page 4 of 4
Prepared By Jonel R Macalisang