0% found this document useful (0 votes)
69 views10 pages

MCTE 4105 Mechatronics Lab Iii Sem Ii - Session 19/20 Title: Experiment 4: Input Switches and Output Leds

This document describes an experiment conducted by students to test input switches and output LEDs using an Arduino Uno microprocessor. The experiment involves 3 tasks - controlling a single LED based on a single switch, multiple LEDs based on multiple switches with delays, and making LEDs light up sequentially with delays. The document provides the objectives, components, schematics, flowcharts, code, discussion, and conclusion for the experiment.

Uploaded by

JAdeking
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)
69 views10 pages

MCTE 4105 Mechatronics Lab Iii Sem Ii - Session 19/20 Title: Experiment 4: Input Switches and Output Leds

This document describes an experiment conducted by students to test input switches and output LEDs using an Arduino Uno microprocessor. The experiment involves 3 tasks - controlling a single LED based on a single switch, multiple LEDs based on multiple switches with delays, and making LEDs light up sequentially with delays. The document provides the objectives, components, schematics, flowcharts, code, discussion, and conclusion for the experiment.

Uploaded by

JAdeking
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/ 10

MCTE 4105

MECHATRONICS LAB III


SEM II || SESSION 19/20

TITLE: EXPERIMENT 4: INPUT SWITCHES AND


OUTPUT LEDS

SEC 1 || GROUP 9

NO NAMES MATRIC NO.


1. MUHAMMAD AIMAN BIN ZAINAL ABIDIN
1625449
2. MUHAMMAD AMMAR FITRI BIN RAMLAN
1626197
3. MUHAMMAD ARIF BIN KAMARUDDIN
1619589
4. WAN AHMAD IZUDDIN BIN WAN JUSOH
1626873

PLEASE LEAVE THIS PART BLANK

DATE OF SUBMISSION TOTAL MARKS

21st July 2020


N CONTENT MARKS
O
1 OBJECTIVES
1.1 To introduce students to the world of microprocessor and its
interfacing.

1.2 To introduce students on how to program an assembler and


transfer the program into the microprocessor and memory.

1.3 To demonstrate basic i/o operation and applications, which is


to read input data from 8-bit DIP Switch (SW1) and Output
the results to 8 LEDs (L1 – L8)
2. COMPONENTS NEEDED
1. Personal Computer
2. Breadboard
3. ILEDs
4. Resistors
5. Switches
6. Arduino UNO / ATMEGA328
3. SCHEMATIC DIAGRAM (ONLY FOR DLD & MICROP)

TASK 1: SINGLE INPUT SINGLE OUTPUT


TASK 2: MULTIPLE INPUT MULTIPLE OUTPUT WITH DELAY

TASK 3: RUNNING LIGHT


4 FLOW CHART (ONLY MICROP)
Task 1: Single input single output

Start

Set all bit high


Set port D & port C as
output

Display output (LED)


from input pinC

End

Task 2: Multiple input multiple output

Task 3: Running light


5 CODING (ONLY FOR MICROP)
Task 1: Single input single output
UIAM: // FUNCTION NAME START LOOP START
LDI R16, $FF // SET ALL BIT R16 HIGH
OUT DDRD, R16 //SET PORT D AS OUPUT
OUT DDRC, R16 // SET PORT C AS OUTPUT
IN R17, PINC //STORE INPUT FROM PIN C TO R17
OUT PORTD, R17 //SEND OUTPUT FROM R17 TO PORT D
RJMP UIAM //PROGRAM JUMP TO START

Task 2: Multiple input multiple output


UIAM: // FUNCTION NAME START LOOP START
LDI R16, $FF // SET ALL BIT R16 HIGH
OUT DDRD, R16 //SET PORT D AS OUPUT
OUT DDRC, R16 // SET PORT C AS OUTPUT
IN R17, PINC //STORE INPUT FROM PIN C TO R17
OUT PORTD, R17 //SEND OUTPUT FROM R17 TO PORT D
CALL DELAY // CALL DELAY FUNTION
RJMP UIAM //PROGRAM JUMP TO START
DELAY: //DELAY TIME
LDI R19,163
LDI R20,87
LDI R21,10
L1:
DEC R21
BRNE L1
DEC R20
BRNE L1
DEC R19
BRNE L1 NOP RET
Task 3: Running light
UIAM: // FUNCTION NAME START LOOP START
LDI R16, $FF // SET ALL BIT R16 HIGH
OUT DDRD, R16 //SET PORT D AS OUPUT
LDI R17,0b00001000
OUT PORTD, R17 //FIRST LED WILL LIGHT UP
CALL DELAY //CALL FUNCTION DELAY
LDI R17,0b00010000
OUT PORTD, R17 //SECOND LED WILL LIGHT UP
CALL DELAY //CALL FUNCTION DELAY
LDI R17,0b00100000
OUT PORTD, R17 //LAST LED WILL LIGHT UP
CALL DELAY //CALL FUNCTION DELAY
RJMP UIAM
DELAY: //DELAY TIME
LDI R18,163
LDI R19,87
LDI R20,10
L1:
DEC R20
BRNE L1
DEC R19
BRNE L1
DEC R18
BRNE L1
NOP
RET

8. DISCUSSION
In this experiment, we test how the microprocessor work with the
Atmel Studio 7.0 application. The Atmel application is application that
use assembly language which control directly to the output and input
port. We utilize port B, port C and port D in the Arduino UNO as output.
To turn on the pin at the output, we use the Atmel Studio to program the
flow work of the microprocessor.

For the first task, we set all the bit to high by setting the value to
$FF which make all 8 bits turned high. Then we set the value into port D
thus making it as output. Port C will become as input pin where we
connect it with switch. As there is high value comes from the switch after
we press it, the LED will be high. Second task relate to different input by
using two switches connect to Analog Input pinA2 and pinA3. The output
pin should be same with the input, pinD2 and pin3D. If only pinA2 is set
high from its pressed switch, the input from port C will be 00000010. The
value then be sent to port D which only pinD2 will be high thus the LED
attached to it will light on. The third experiment relate to delay where we
code the program to make the three LEDs will light on with delay.
Task1 :

Task2 :
Task 3:

Video for Experiment 4:


https://youtu.be/AXJ-_hU8FC8

9. CONCLUSION
To conclude, all three experiment is success with the LED give
the output according to the instruction thus showing the coding and
circuit’s set-up is in correct position. The using of assembly language is
should be done very carefully because of its critical detail. The using of
different pin or port may cause different result.

You might also like