Digielecs 2 Lab Experiment 2
Digielecs 2 Lab Experiment 2
Digielecs 2 Lab Experiment 2
University
College of Engineering and Architecture
Electronics Engineering Department
Villa de Bacolor, Pampanga
NAME OF STUDENT:
GROUP NUMBER: 11 DATE PERFORMED: 3/6/23
COURSE CODE: ELECS 3 DATE SUBMITTED:3/14/23
COURSE TITLE: Digital Electronics 2 Lab YEAR AND SECTION: ECE – 3A
LAB. INSTRUCTOR: Engr. Enmar T. Tuazon GRADE:
OBJECTIVE
1. Interfacing output devices on Arduino.
2. Utilizing functions
DISCUSSION
PROCEDURE:
Connection Diagram
Connection Diagram
Connection Diagram
int timer = 100;
void setup() {
// use a for loop to initialize each pin as an
output: for (int ece = 2; ece < 8; ece++) {
pinMode(ece, OUTPUT);
}
}
void loop() {
// loop from the lowest pin to the highest:
for (int ece = 2; ece < 8; ece++) {
// turn the pin on:
digitalWrite(ece, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ece, LOW);
}
ACTIVITY
Sequence 1:
• Once the power has been plug, it will have a delay of 2s to turn on the first LED. After
2s, the first LED will turn on and won’t turn off. After 4s after the power has been plug, the
second LED will turn on and also won’t turn off. The third LED will turn on after 6s until the
last LED has been reached, and an additional of 2s delay to turn on is being added to each LED.
After the last LED turn on, they will turn off individually starting from the last LED with a delay
of 500 ms for each interval.
Sequence 2:
• LED # 2,4,6,8 will turn on for 2s and turn off. Without delay, the remaining LED will
turn on for the same delay. This sequence will repeat 3 times.
Sequence 3:
• Binary Counting starting from 0 to 256
DISCUSSIONS:
OBSERVATIONS:
PHOTODOCUMENTATIONS:
Sequence 1:
Sequence 2:
Sequence 3:
CONCLUSION:
REFERENCES:
CODES:
Sequence 1:
const int ledWhite = 11;
const int ledGreen = 10;
const int ledYellow = 9;
const int ledRed = 8;
const int ledBlue = 7;
const int ledWhite2 = 6;
const int ledGreen2 = 5;
const int ledYellow2 = 4;
void setup(){
pinMode(ledWhite, OUTPUT);
pinMode(ledGreen, OUTPUT);
pinMode(ledYellow, OUTPUT);
pinMode(ledRed, OUTPUT);
pinMode(ledBlue, OUTPUT);
pinMode(ledWhite2, OUTPUT);
pinMode(ledGreen2, OUTPUT);
pinMode(ledYellow2, OUTPUT);
}
void loop()
{
digitalWrite(ledWhite, HIGH);
delay(2000);
digitalWrite(ledGreen, HIGH);
delay(2000);
digitalWrite(ledYellow, HIGH);
delay(2000);
digitalWrite(ledRed, HIGH);
delay(2000);
digitalWrite(ledBlue, HIGH);
delay(2000);
digitalWrite(ledWhite2, HIGH);
delay(2000);
digitalWrite(ledGreen2, HIGH);
delay(2000);
digitalWrite(ledYellow2, HIGH);
delay(500);
digitalWrite(ledYellow2, LOW);
delay(500);
digitalWrite(ledGreen2, LOW);
delay(500);
digitalWrite(ledWhite2, LOW);
delay(500);
digitalWrite(ledBlue, LOW);
delay(500);
digitalWrite(ledRed, LOW);
delay(500);
digitalWrite(ledYellow, LOW);
delay(500);
digitalWrite(ledGreen, LOW);
delay(500);
digitalWrite(ledWhite, LOW);
delay(2000);
Sequence 2:
const int LED1 = 4;
const int LED2 = 5;
const int LED3 = 6;
const int LED4 = 7;
const int LED5 = 8;
const int LED6 = 9;
const int LED7 = 10;
const int LED8 = 11;
int Repeat = 0;
void setup() {
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
pinMode(LED4,OUTPUT);
pinMode(LED5,OUTPUT);
pinMode(LED6,OUTPUT);
pinMode(LED7,OUTPUT);
pinMode(LED8,OUTPUT);
}
void loop(){
if(Repeat<3) {
digitalWrite(LED2, HIGH);
digitalWrite(LED4, HIGH); A
digitalWrite(LED6, HIGH);
digitalWrite(LED8, HIGH);
delay(2000);
digitalWrite(LED2, LOW);
digitalWrite(LED4, LOW);
digitalWrite(LED6, LOW);
digitalWrite(LED8, LOW);
digitalWrite(LED1, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED5, HIGH);
digitalWrite(LED7, HIGH);
delay(2000);
digitalWrite(LED1, LOW);
digitalWrite(LED3, LOW);
digitalWrite(LED5, LOW);
digitalWrite(LED7, LOW);
Repeat = Repeat + 1;
}
}
Sequence 3:
void setup()
{
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}
void loop()
{
for(byte i=0;i<255;i++)
{ byte v=i%2;
byte j=i/2 %2;
byte a=i/4 %2;
byte y=i/8 %2;
byte d=i/16 %2;
byte u=i/32 %2;
byte k=i/64 %2;
byte s=i/128 %2;
digitalWrite(4,v);
digitalWrite(5,j);
digitalWrite(6,a);
digitalWrite(7,y);
digitalWrite(8,d);
digitalWrite(9,u);
digitalWrite(10,k);
digitalWrite(11,s);
delay(200);
}
}