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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/18/99 22:51
Read: times


 
#662 - RE: blinking LEDs
Suppose that u read data from ur A/D converter in port1 (P1).
A simple translation of ur problem.
LED 1 is on when T>75 (P2.0)
CLR p2.0 = turn off LED1
SETB p2.0 = turn on LED1
LED 2 is on when T<60 (P2.1)

When 60=<T<=75 then LED1,LED2=off.
The base of the demonstration code below is the instruction :
CJNE A,#data,label
when A<data then CY is set
___________________________________

ORG 0000H
CLR C
MOV A,P1 ;READ UR DATA FROM PORT1
CJNE A,#60,CHECK1
CLR P2.0 ; A=60
CLR P2.1
AJMP 0000H

CHECK1:
JNC UP ;IF A>60 CY=0 JMP TO UP
;ELSE A<60
SETB P2.1 ; TURN ON LED 2
AJMP 0000H

UP:
CJNE A,#75,CHECK2
CLR P2.0 ; A=75
CLR P2.1
ajmp 0000h

CHECK2:
JNC UPUP ;IF A>75 cy=0 JMP TO UPUP
;ELSE A<75
CLR P2.0
CLR P2.1
AJMP 0000H

UPUP: ; a>75
SETB P2.0 ;TURN ON LED1
AJMP 0000H


bEWARE the above code is demo.
U will need delays,and another routines in a real situation and of course everything depents on ur hardware
Good luck
Vasilis

List of 3 messages in thread
TopicAuthorDate
blinking LEDs            01/01/70 00:00      
RE: blinking LEDs            01/01/70 00:00      
RE: blinking LEDs            01/01/70 00:00      

Back to Subject List