0% found this document useful (0 votes)
66 views12 pages

Practical Assesment 2 Q - Nabil

The document describes a practical assessment for an embedded systems course. Students are asked to program an Arduino microcontroller to control 7 LEDs in 3 different blinking patterns using switches as inputs. The microcontroller pin assignments and circuit connections are provided. Students must write code to control the LED patterns and submit the code and a flowchart describing the patterns. The goal is for students to learn to use and program a microcontroller's internal peripherals for parallel I/O applications.

Uploaded by

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

Practical Assesment 2 Q - Nabil

The document describes a practical assessment for an embedded systems course. Students are asked to program an Arduino microcontroller to control 7 LEDs in 3 different blinking patterns using switches as inputs. The microcontroller pin assignments and circuit connections are provided. Students must write code to control the LED patterns and submit the code and a flowchart describing the patterns. The goal is for students to learn to use and program a microcontroller's internal peripherals for parallel I/O applications.

Uploaded by

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

DPP C2(e)-1

MARA - Japan Industrial Institute,


Beranang, Selangor

PRACTICAL ASSESSMENT 2

PROGRAMME DIPLOMA IN ELECTRONIC ENGINEERING


SESSION APRIL – AUGUST 2021 SEMESTER 3

DFV20153
CODE & COURSE MICROCONTROLLER AND SHEET NO A2 (1)
EMBEDDED SYSTEM

LECTURER MOHD ALIFUDDIN BIN MOHD JALANI DURATION 2 HOURS

STUDENT NAME MUHAMMAD NABIL BIN MOHAMED HISSAM

CLASS SHIBUYA

TOPIC LED PATTERN BLINK WITH SWITCH

SUB-TOPIC Unit 6.0 Internal Peripherals

After completing the practical, students should be able to:


LEARNING
OUTCOME 1. Identify the peripherals pin in a microcontroller
2. Use and program the device for parallel I/O application

1. Arduino ATmega2560 R3 or ATmega328 (UNO) R3


2. 3 pcs switch
3. 7 pcs LED
Tools/Equipment 4. 7 pcs Resistor (220-330ohm).
5. Proto-board/Breadboard.
6. Jumper wire (as required).
7. Arduino IDE sketch software

Page 1 of 3
DPP C2(e)-1

A) Assign microcontroller pinout (refer to Appendix):


1. Fill in Pin Number (of your choice) base on the microcontroller used
(mark [√]):
Table 1: Pin number

ATmega2560 (MEGA) microcontroller


ATmega328 (UNO) microcontroller

Switch SW1 SW2 SW3


2 3 4
Pin No.

LED LED1 LED2 LED3 LED4 LED5 LED6 LED7


7 8 9 10 11 12 13
Pin No.

B) Install component in TinkerCAD


1. Install 1 piece of LED and resistor to each pin assigned in Table 1
on a breadboard.
INSTRUCTION / 2. Connect each LED’s cathode to ground (0V).
QUESTION
3. Install ALL switches with PULLUP function enable, which is
configured as ACTIVE LOW.

C. Write a programming code in TinkerCAD


1. Design a programming code with 3 different blinking patterns.
2. When turned on, LED7 will light up as default/origin state.
3. Switch 1, 2 and 3 will change the pattern such below:

Switch Press 1x Press 2x Press 3x Press 4x


Origin  Pattern 1 Pattern 2 Pattern 3 
Switch 1
Pattern 1 Pattern 2 Pattern 3 Origin
Pattern 3  Pattern 2 – Pattern 1 
Switch 2 --
Pattern 2 Pattern 1 Origin
Any state
Switch 3 -- -- --
 Origin

Page 2 of 3
DPP C2(e)-1

D. Submission
Rename the project in TinkerCAD as “Practical Assessment 2”
Copy the programming code in word.
Illustrate a functional flow chart for the programming, simplify each
blinking pattern as 1 block pattern only.
Programming code and block diagram must be submitted through
Microsoft Teams Assignment.

Page 3 of 3
DPP C2(e)-1
Appendix
ATMEL ATmega 2560 100-pins layout:

ATMEL ATmega328 (UNO) 28 pins layout:

Page 4 of 3
DPP C2(e)-1

Page 5 of 3
DPP C2(e)-1

Page 6 of 3
DPP C2(e)-1

Page 7 of 3
DPP C2(e)-1
int LEDarray[]={7,8,9,10,11,12,13};
int i=0,flag=0,LEDtotal=7;
int SW01,SW02,SW03;

void setup() {
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
}

void loop(){
SW01=digitalRead(2);
SW02=digitalRead(3);
SW03=digitalRead(4);

if(SW01==LOW){
flag=flag+1;
delay(1000);
}
else if(SW02==LOW){
flag=flag-1;
}
else if(SW03==LOW){
flag=0;
}

if(flag==+1)
{
for(i=0;i<LEDtotal;i++){
digitalWrite(LEDarray[i], HIGH);
delay(500);
digitalWrite(LEDarray[i], LOW);
delay(300);
}
}
else if(flag==-1){
for(i=LEDtotal-1;i>=0;i--){
digitalWrite(LEDarray[i], HIGH);
delay(500);
digitalWrite(LEDarray[i], LOW);
delay(300);
}
}
else if(flag==2){
for(i=LEDtotal-1;i>=0;i--){
digitalWrite(LEDarray[i], HIGH);
delay(500);

}
}
Page 8 of 3
DPP C2(e)-1
else if(flag==3){
for(i=LEDtotal-1;i>=0;i--){
digitalWrite(LEDarray[i], LOW);
delay(500);

}
}

else{
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
}
}

Page 9 of 3
DPP C2(e)-1

Start

LEDarray={7,8,9,10,11,12,13}
i=0,flag=0,LEDtotal=7
SW01,SW02,SW03

yes
flag=flag+1;
SW01==LOW
delay(1000);

no

yes
flag=flag-1
SW02==LOW

no

yes
flag=0
SW03==LOW

no

flag==+1

yes digitalWrite(LEDarray[i], HIGH);


delay(500);
i=0;i<LEDtotal;i++ digitalWrite(LEDarray[i], LOW);
delay(300);

Page 10 of
3
DPP C2(e)-1

no

flag== -1

digitalWrite(LEDarray[i], HIGH);
delay(500);
i=LEDtotal-1;i>=0;i--
digitalWrite(LEDarray[i], LOW);
delay(300);

no

flag==2

digitalWrite(LEDarray[i], HIGH);
delay(500);
i=LEDtotal-1;i>=0;i--

no

flag==3

digitalWrite(LEDarray[i], LOW);
i=LEDtotal-1;i>=0;i-- delay(500);

no

else

Page 11 of
3
DPP C2(e)-1

digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);

Page 12 of
3

You might also like