Microcontroller › 8051 › how to display a 4-digit numeric data on 7-seg displays with variable data at receiver › i have made the following
i have made the following code.this code receives the data byte serially in ascii and then displays it on seven segment display. check it there might be some errors as i was in a hurry.also if you want that the digits remain displayed if transistor is off then use a latch to store the data.
org 0
mov tmod,#20h
mov th1,#-6
mov scon,#50h
setb tr1
there: mov r3,#04h
now: jnb r1,now
mov dptr,#900h
mov a,sbuf
anl a,#07h
movc a,@a+dptr
mov p0,a
acall disp
back: djnz now
sjmp there
disp: cjne r3,#04h,next
mov p2,#01h
ljmp back
next: cjne r3,#03h,next1
mov p2,#02h
ljmp back
next1: cjne r3,#02h,next2
mov p2,#04h
ljmp back
next2: cjne r3,#01h,back
mov p2,#08h
ret
org 900h
[write the seven segment codes here one by one starting with 0-9]