1.Tujuan [kembali]
Mempelajari cara pengaplikasian MCS51 pada Seven Segment
2. Alat [kembali]
*SEVEN SEGMENT
*SWITCH
*80C51
3.Teori [kembali]
4.Rangkaian [kembali]
5.Program [kembali]
#include <REGX51.H>
sbit input1=P1^0;
sbit input2=P1^1;
sbit input3=P1^2;
void msdelay (unsigned int) ;
void msdelay (unsigned int value){
unsigned int x, y;
for (x=0; x<value; x++)
for (y=0; y<1275; y++);
}
void main(void){
P2=0x00;
P1=0xff;
while (1){
if (input1==1) //switch 1 on
{P2=0x08;
msdelay (50);
P2=0x04;
msdelay (50);
P2=0x00;
msdelay (50);
}
else if (input2==1) //switch 2 on
{P2=0x00;
msdelay (50);
P2=0x04;
msdelay (50);
P2=0x08;
msdelay (50);
}
else if(input3 == 1)
{P2=0x01;
msdelay (50);
P2=0x05;
msdelay (50);
P2=0x01;
msdelay (50);
P2=0x00;
msdelay (50);
P2=0x09;
msdelay (50);
P2=0x05;
msdelay (50);
P2=0x01;
msdelay (50);
P2=0x00;
msdelay (50);
P2=0x05;
msdelay (50);
P2=0x02;
msdelay (50);
}
}
}




Tidak ada komentar:
Posting Komentar