0% found this document useful (0 votes)
37 views4 pages

Act3 Arduino Burgos

This document describes a laboratory exercise using an Arduino Uno board to program 8 LEDs in a running lights pattern. The objectives are to familiarize students with the Arduino IDE and basic functionality. The procedure involves writing code to light the LEDs moving from left to right or right to left using for loops. Functions like digitalWrite(), pinMode(), and delay() are used to control the LEDs. Modifying the code to move the lights back and forth continuously is suggested as an exercise. The conclusion states the experiment helps guide students on basic Arduino programming and familiarizes them with functions used to control inputs and outputs.

Uploaded by

Charles Burgos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

Act3 Arduino Burgos

This document describes a laboratory exercise using an Arduino Uno board to program 8 LEDs in a running lights pattern. The objectives are to familiarize students with the Arduino IDE and basic functionality. The procedure involves writing code to light the LEDs moving from left to right or right to left using for loops. Functions like digitalWrite(), pinMode(), and delay() are used to control the LEDs. Modifying the code to move the lights back and forth continuously is suggested as an exercise. The conclusion states the experiment helps guide students on basic Arduino programming and familiarizes them with functions used to control inputs and outputs.

Uploaded by

Charles Burgos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

LABORATORY EXERCISE #3

RUNNING LIGHTS
OBJECTIVE(S):
1. To familiarize the student with the basic operation of the Arduino Uno board, and
Integrated
Development Environment (IDE).
2. To be able to know the basic functionalities of the IDE.

REQUIREMENTS:
1 Arduino Uno board and USB cable
8 LEDs
8 Resistors (optional)
1 Breadboard
Connecting wires
PROCEDURE:
1. Problem: Using 8 LED’s as output, write a code/program that will perform the LED’s
move:
OPTION 1: from Left to Right
OPTION 2: from Right to Left
2. Save your file and compile it.
3. Test your program.
4. Record the result/output. (Include discussion of output operation.)
DATA & RESULTS:

 Copy of Codes/Program with Comments

int del = 500; // making the delay 500 ms


void setup() {

pinMode(2, OUTPUT); //declaring pins 2-9 as Outputs


pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}

void loop() {

for (int i = 2; i <= 9; i++) { // For loop will count from 2 to 13 to turn ON and OFF every
single pin
digitalWrite(i, HIGH); // Turning ON 1st output (LED)
delay(del); // LED is ON for 20ms before turning OFF
digitalWrite(i, LOW); // Turning OFF 1st output (LED)
delay(del); // Waiting 20ms before running the 2nd cycle of FOR loop
}
}

 Output/Result (Include discussion of output operation.)


EXERCISES:
1. Modify your written code/program of Running lights by removing the option.
 Code the program efficiently by using looping functions.
 What to expect: Lights will move from Left to Right then Right to Left, continuously.

int del = 500; // making the delay 500 ms


void setup() {

pinMode(2, OUTPUT); //declaring pins 2-9 as Outputs


pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {

for (int i = 2; i <= 9; i++) { // For loop will count from 2 to 13 to turn ON and OFF every
single pin
digitalWrite(i, HIGH); // Turning ON 1st output (LED)
delay(del); // LED is ON for 20ms before turning OFF
digitalWrite(i, LOW); // Turning OFF 1st output (LED)
delay(del); // Waiting 20ms before running the 2nd cycle of FOR loop
}

for (int i = 9; i >= 2; i--) { // For loop will count from 13 to 2 to turn ON and OFF every
single pin
digitalWrite(i, HIGH); // Turning ON 1st output (LED)
delay(del); // LED is ON for 20ms before turning OFF
digitalWrite(i, LOW); // Turning OFF 1st output (LED)
delay(del); // Waiting 20ms before running the 2nd cycle of FOR loop
}
}

2. What function enables you to read the input from a pin?

To read the state of the input pin, the Digital Read function is used.
This function returns either logical HIGH or logical LOW input for digitalRead. If the pin's
input state is HIGH, it returns HIGH and low, respectively.

3. What function enables you to program efficiently the lighting up of several LED’s?

digitalWrite() function is the one that enables the program writer to light a specific
LED’s.
Digital write writes a HIGH or a LOW value to a digital pin. If the pin is configured as an
INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the
input pin.

4. How would you change the amount of time each LED is ON?

We can change the amount of time each LED is ON, by using the delay(ms) function.
Pauses the program for the amount of time (in milliseconds) specified as parameter.
(There are 1000 milliseconds in a second.)
SUMMARY & CONCLUSION:
The experiment was able to guide a student on how-to-do basic Arduino programs, such
as the running lights in this experiment. Experimenting helped to provide a guide for
familiarizing how to code in Arduino UNO. There is also background on what are some of the
functions that can be used in programming an Arduino.
Performing this experiment has given us an understanding of what are the things that
needed to be familiarized with the basic operation of Arduino. Integrating the program inside
the Arduino is also one of the key importance of this activity. It helps us to learn what should
we do, how should we program an Arduino, and vice versa.

You might also like