Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/31/01 11:29
Read: times


 
#18219 - RE: Led/Button
Eric's connection is right, but I find a problem in sharing a single IO pin in this application:

Once the led is ON (output = 0), any input readings will give a result of '0', regardles the pushbutton state.

One possible solution is to turn OFF the led for a short period of time, and read the pushbutton state before restoring the output state. The 'current' led state must be stored in RAM (bit ledstate).

This procedure should be followed any time the pushbutton state is to be read.

led bit P1.0
ledstate bit 0
buttonstate bit 1
...
; Returns pushbutton state in C
getbuttonstate:
setb led
nop ; optional delay
mov c,led
mov buttonstate,c
mov c,ledstate ; restore led state
mov led,c
ret

ledon:
clr ledstate ; mark the ram copy
clr led ; set the led ON
ret

ledoff:
setb ledstate ; mark the ram copy
setb led ; set the led OFF
ret

Regards,

Alfredo del Rio.


List of 4 messages in thread
TopicAuthorDate
Led/Button            01/01/70 00:00      
RE: Led/Button            01/01/70 00:00      
RE: Glow after the button release :(            01/01/70 00:00      
RE: Led/Button            01/01/70 00:00      

Back to Subject List