Binary 1's and 0's Counter
Binary 1's and 0's Counter
org 0000h
mov r5,#08h
mov r0,#00h
mov r1,#00h
mov a,#89h
label2: rrc a
jc label1
inc r0
sjmp here
label1:inc r1
end
Square Wave 1:
org 0000h
mov tmod,#10h
cpl p2.4
mov tl1,#00h
setb tr1
clr tr1
clr tf1
djnz r0,back
sjmp rep
end
Square wave 2:
org 0000h
mov tmod,#01h
mov th0,#0b8h
mov p0,#00h
acall delay
mov tl0,#8ah
mov th0,#0e4h
mov p0,#0ffh
acall delay
sjmp rep
org 0030h
clr tr0
clr tf0
ret
end
LCD Interfacing:
;Call a time delay before sending next data/command
ORG 0000H
MOV DPTR,#MYCOM
C1: CLR A
MOVC A,@A+DPTR
JZ SEND_DAT
INC DPTR
SJMP C1
D1: CLR A
MOVC A,@A+DPTR
INC DPTR
JZ AGAIN
SJMP D1
RET
RET
DJNZ R3,HERE2
RET
ORG 300H
END
Matrix Keypad:
#include<REGX51.H>
void main(void)
KROW1 = 0;
KROW2 = 0;
KROW3 = 0;
KCOL1 = 1;
KCOL2 = 1;
KCOL3 = 1;
while(1)
if( i == 0)
KROW0 = 0;
KROW1 = 1;
KROW2 = 1;
KROW3 = 1;
if(KCOL0 == 0)
while(KCOL0 == 0);
key_status = 1;
if(KCOL1 == 0)
while(KCOL1 == 0);
key_status = 2;
}
if(KCOL2 == 0)
while(KCOL2 == 0);
key_status = 3;
if(KCOL3 == 0)
while(KCOL3 == 0);
key_status = 4;
if( i == 1)
KROW0 = 1;
KROW1 = 0;
KROW2 = 1;
KROW3 = 1;
if(KCOL0 == 0)
while(KCOL0 == 0);
key_status = 5;
if(KCOL1 == 0)
while(KCOL1 == 0);
key_status = 6;
if(KCOL2 == 0)
while(KCOL2 == 0);
key_status = 7;
if(KCOL3 == 0)
while(KCOL3 == 0);
key_status = 8;
if( i == 2)
KROW0 = 1;
KROW1 = 1;
KROW2 = 0;
KROW3 = 1;
if(KCOL0 == 0)
while(KCOL0 == 0);
key_status = 9;
if(KCOL1 == 0)
{
while(KCOL1 == 0);
key_status = 10;
if(KCOL2 == 0)
while(KCOL2 == 0);
key_status = 11;
if(KCOL3 == 0)
while(KCOL3 == 0);
key_status = 12;
if( i == 3)
KROW0 = 1;
KROW1 = 1;
KROW2 = 1;
KROW3 = 0;
if(KCOL0 == 0)
while(KCOL0 == 0);
key_status = 13;
}
if(KCOL1 == 0)
while(KCOL1 == 0);
key_status = 14;
if(KCOL2 == 0)
while(KCOL2 == 0);
key_status = 15;
if(KCOL3 == 0)
while(KCOL3 == 0);
key_status = 16;
LEDPORT = ~key_status;
}
7 Segment Display:
#include <REGX51.H>
void delay(void);
void ldelay(void);
void dis_key(void);
void main(void)
digi0 = 0;
digi1 = 0;
digi2 = 0;
digi3 = 0;
DATAPORT = 0x00;
key_1 = 1;
key_2 = 1;
key_3 = 1;
key_4 = 1;
while(1)
digi0 = 1;
digi1 = 0;
digi2 = 0;
digi3 = 0;
ldelay();
DATAPORT = 0x4A;
digi0 = 0;
digi1 = 1;
digi2 = 0;
digi3 = 0;
ldelay();
digi0 = 0;
digi1 = 0;
digi2 = 1;
digi3 = 0;
ldelay();
DATAPORT = 0xF5; //0000 1000
digi0 = 0;
digi1 = 0;
digi2 = 0;
digi3 = 1;
ldelay();
void ldelay(void)
unsigned char i;