This program needs to be written in assembly language please comment liberally.
ID: 642053 • Letter: T
Question
This program needs to be written in assembly language please comment liberally.
The purpose of this lab is to control the outputs of the micro-controller in a given sequence. Green and red Light Emitting Diodes (LEDs) are connected to the micro-controller outputs.
Steps
First, write a program to turn on only one LED and then turn off the same LED.
Improve the program by making the LED blink.
The next part of the lab is to read the input switches, one from the Walk push button and the other indicating a car at the crossing. As switches are mechanical objects, some de-bounce time (dead time) will also be placed in the program. You will control each LED with one switch; as long as the switch is active the respective LED is ON and when switch is inactive, the corresponding LED is OFF. Then, the LED will be made to blink as long as switch is ON.
Finally, you will write a little traffic light controller where the green or red stays ON while the corresponding switch is ON. If more than one switch is activated, then ON the red light.
LED's simulate the traffic lights and the switches simulate the walk push button and the car presence sensor at a crossroad.
Input and Output Assignment
P3.1 pin 19 active Low Input, SW1 (Walk push button)
P3.2 pin 18 active Low Input, SW2 (Car present at the crossing))
P1.3 pin 9 Output active High, Red LED
P1.1 pin 11 Output, active High, Green LED
The purpose of this lab is to control the outputs of the micro-controller in a given sequence. Green and red Light Emitting Diodes (LEDs) are connected to the micro-controller outputs.
Steps
First, write a program to turn on only one LED and then turn off the same LED.
Improve the program by making the LED blink.
The next part of the lab is to read the input switches, one from the Walk push button and the other indicating a car at the crossing. As switches are mechanical objects, some de-bounce time (dead time) will also be placed in the program. You will control each LED with one switch; as long as the switch is active the respective LED is ON and when switch is inactive, the corresponding LED is OFF. Then, the LED will be made to blink as long as switch is ON.
Finally, you will write a little traffic light controller where the green or red stays ON while the corresponding switch is ON. If more than one switch is activated, then ON the red light.
LED's simulate the traffic lights and the switches simulate the walk push button and the car presence sensor at a crossroad.
Input and Output Assignment
P3.1 pin 19 active Low Input, SW1 (Walk push button)
P3.2 pin 18 active Low Input, SW2 (Car present at the crossing))
P1.3 pin 9 Output active High, Red LED
P1.1 pin 11 Output, active High, Green LED
Explanation / Answer
Step 1:Program to turn on only one LED and then turn off the same LED:
So the logic behind this problem would be when the Port Pin is HIGH the LED is OFF & when the Port Pin is LOW the LED is turned ON.
And, the port pin is connected to P2.0
ORG 0000h
loop:
CLR P2.0
CALL DELAY
SETB P2.0
CALL DELAY
JMP loop
Step 2:Led Blink program:
delay:
mov r0, a
dly2: mov r1, #230
dly3: nop
nop
nop
nop
nop
nop
djnz r1, dly3
djnz r0, dly2
ret
Step 3:Reading the input switches
int pinButton = 8;
int LED = 2;
int stateLED = LOW;
int stateButton;
int previous = LOW;
long time = 0;
long debounce = 200;
void setup() {
pinMode(pinButton, INPUT);
pinMode(LED, OUTPUT);
}
void loop() {
stateButton = digitalRead(pinButton);
if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {
if(stateLED == HIGH){
stateLED = LOW;
} else {
stateLED = HIGH;
}
time = millis();
}
digitalWrite(LED, stateLED);
previous == stateButton;
}
Step 4:Traffic light controller
org 0000h
here:
mov p0,#0d4h
acall delay1
mov p0,#53h
acall delay1
mov p0,#4dh
acall delay1
mov p0,#35h
acall delay1
sjmp here
delay1:
MOV R2,#42d
MOV R1,#00d
MOV R0,#00d
loop: DJNZ R0,loop
DJNZ R1,loop
DJNZ R2,loop
RET
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.