Professional Documents
Culture Documents
COMPTECH 315 BIT III B Module 02 LED DISPLAY WITH SLIDESWITCH Part 1
COMPTECH 315 BIT III B Module 02 LED DISPLAY WITH SLIDESWITCH Part 1
COLLEGE OF TECHNOLOGY
Course Subject : COMPTECH 315 (Microprocessor System) Room No. : Room 311
MODULE 02
LED DISPLAY WITH SLIDESWITCH – PART 1
LEARNING OBJECTIVES:
To construct a microprocessor/microcontroller circuit using Arduino Uno with slideswitches as input
components and resistors and light-emitting diodes (LEDs) as output components.
To program a microprocessor/microcontroller circuit based on the required output. In this module, the
required output is to light the LEDs based on the following conditions:
Left-To-Right when switch 1 is on, switch 2 is off, and switch 3 is off.
Right-To-Left when switch 1 is off, switch 2 is on, and switch 3 is off.
Both Sides-To-Center and Center-To-Both Sides when switch 1 is off, switch 2 is off, and switch 3 is
on.
LIST OF COMPONENTS:
CIRCUIT DIAGRAM:
Republic of the Philippines
CEBU TECHNOLOGICAL UNIVERSITY
NAGA EXTENSION CAMPUS
Central Poblacion, City of Naga, Cebu, Philippines
Website: http://www.ctu.edu.ph E-mail: ctunagaextensioncampus@gmail.com
Phone: +6332 417 0418
COLLEGE OF TECHNOLOGY
SOURCE CODE:
#define inputSwitch1 10
#define inputSwitch2 11
#define inputSwitch3 12
int i,temp;
int displayLED1[8]={2, 3, 4, 5, 6, 7, 8, 9};
int displayLED2[8]={2, 3, 4, 5, 6, 7, 8, 9};
int displayLED3[8]={2, 3, 4, 5, 6, 7, 8, 9};
void setup() {
for(i=0;i<8;i++) //i++ --> i = i + 1 --> i += 1
pinMode(displayLED1[i], OUTPUT);
for(i=0;i<8;i++)
digitalWrite(displayLED1[i], LOW);
delay(300);
}
void loop() {
switchStatus1 = digitalRead(inputSwitch1);
Republic of the Philippines
CEBU TECHNOLOGICAL UNIVERSITY
NAGA EXTENSION CAMPUS
Central Poblacion, City of Naga, Cebu, Philippines
Website: http://www.ctu.edu.ph E-mail: ctunagaextensioncampus@gmail.com
Phone: +6332 417 0418
COLLEGE OF TECHNOLOGY
switchStatus2 = digitalRead(inputSwitch2);
switchStatus3 = digitalRead(inputSwitch3);
delay(10);
if(switchStatus1 == HIGH && switchStatus2 == LOW && switchStatus3 == LOW) {
//delay(10);
for(i=0;i<8;i++) {
digitalWrite(displayLED1[i], HIGH);
delay(300);
digitalWrite(displayLED1[i], LOW);
}
}
Republic of the Philippines
CEBU TECHNOLOGICAL UNIVERSITY
NAGA EXTENSION CAMPUS
Central Poblacion, City of Naga, Cebu, Philippines
Website: http://www.ctu.edu.ph E-mail: ctunagaextensioncampus@gmail.com
Phone: +6332 417 0418
COLLEGE OF TECHNOLOGY
for(i=0;i<8;i++)
digitalWrite(displayLED1[i], LOW);
delay(300);
temp = 4;
for(i=3;i>=0;i--) {
digitalWrite(displayLED2[i], HIGH);
digitalWrite(displayLED3[temp], HIGH);
delay(300);
digitalWrite(displayLED2[i], LOW);
digitalWrite(displayLED3[temp], LOW);
temp++;
}
for(i=0;i<8;i++)
digitalWrite(displayLED1[i], LOW);
delay(300);
}
}
Republic of the Philippines
CEBU TECHNOLOGICAL UNIVERSITY
NAGA EXTENSION CAMPUS
Central Poblacion, City of Naga, Cebu, Philippines
Website: http://www.ctu.edu.ph E-mail: ctunagaextensioncampus@gmail.com
Phone: +6332 417 0418
COLLEGE OF TECHNOLOGY
Submitted To: