You are on page 1of 7

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
1. Rename the project in TinkerCAD as “Practical Assessment 2”
2. Copy the programming code in word.
3. Illustrate a functional flow chart for the programming, simplify each
blinking pattern as 1 block pattern only.
4. 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

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 5 of 3
DPP C2(e)-1

no

flag== -1

digitalWrite(LEDarray[i], HIGH);
i=LEDtotal-1;i>=0;i-- delay(500);
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 6 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 7 of 3

You might also like