MiniProject
MiniProject
อุปกรณ์
1. PIC16F877A
2. IC 7 SEGMENT 7448
3. IC 7400
4. 7 SEGMENT COMMON CATHODE
5. CRYSTAL 4MHz
6. CAPACITOR 22pF
Code
{
unsigned char dice[]={0b00000001,0b00000010,0b00000011,0b00000100,0b00000101,0b00000110,0b00000111,0b00001000,0b00001001};
unsigned char i;
unsigned char Num[]= {0b00010000,0b00100000,0b00110000,0b01000000,0b01010000,0b01100000,0b01110000,0b10000000,0b10010000
,0b00000001,0b00010001,0b00100001,0b00110001,0b01000001,0b01010001,0b01100001,0b01110001,0b10000001,0b10010001,0b00000010
,0b00010010,0b00100010,0b00110010,0b01000010};
unsigned char a;
TRISB=0xFF;
TRISC=0;
TRISD=0;
PORTD=0;
PORTB =1;
while(1)
{
if(PORTB.F0==0)
{
PORTD=dice[i];
while(PORTB.F0==0);
i++;
}
PORTC=Num[a];
delay_ms (400);
a++;
if(a>24)a=0;
if(PORTB.F7==0)
{
PORTD=0;
i=0;
}
if(i>20)i=0;
}
}
ความคิดเห็น
แสดงความคิดเห็น