if a switch is closed the corrosponding LED PRACTICAL INTERF
if a switch is closed, the corrosponding LED
PRACTICAL INTERFACING PROGRAMS Program 3: Interfacing Binary Switches If a switch is closed, the comesponding LED turns on (Figure 6.16) BASE EOU $1000 PORTS EQ0 504 ORG SCI00 STAA FORTS,Xsturn oft LEDS LDAA #00 STAA DORC. rporte is input REPEAT PORTC,X sget status of switches STAA PORTB, x BRA REPEAT END corresponding LaDis : turn on cocresponding LEDs ikeep going Exercises 1. Modify Program 3 so that when SWO is closed, all LEDs start flashing 2. If the SPST switches are replaced byshbumons-(PBs), modify the above program so that when any PB is pressed, the conesponding LED turns on and remains Solution
(1)
BASE EQU $1000
PRTB EQU $04
PORTC EQU $03
DDRC EQU $07
ORG $C100
LDX #BASE
LDAA #$FF
STAA PORTB,X ;TURN OFF LEDS
LDAA #00
STAA DDRPB0,X ;swo is stored
LDAA PORTB0,X ;get status of switches
STAA PORTB,X ; turn on corresponding LED\'s
BRA REPEAT ;keep going
END
