Bài 7: PIC Đồng hồ led 7 đoạn
Bài 7: PIC Đồng hồ led 7 đoạn
Bài 7: PIC Đồng hồ led 7 đoạn
Bài 7: PIC Đồng hồ led 7 đoạn
Bài 7: PIC Đồng hồ led 7 đoạn
Bài 7: PIC Đồng hồ led 7 đoạn
Tài liệu
Bài 7: PIC Đồng hồ led 7 đoạn
Yêu cầu: Thiết kế mạch đồng hồ
Thiết bị sử dụng
- PIC 16F887
- 6 IC 74HC595
- 6 Điện trở 220
- 6 led 7 đoạn
Mạch đi dây

Chương trình điều khiển
#define DATA PIN_C1 //DS
#define LATCH PIN_C3 //ST_CP
#define CLOCK PIN_C0 //SH_CP
int giaima7doan[]={63,6,91,79,102,109,125,7,127,111};
//0 1 2 3 4 5 6 7 8 9
void IC_74hc595(int dulieu)
{
int i;
output_low(CLOCK);
for(i=0;i<=7;i++)
{
if((dulieu & 0x80)==0)
output_low(DATA);
else
output_high(DATA);
dulieu=dulieu<<1;
output_high(CLOCK);
output_low(CLOCK);
}
}
void hienthi2so(int num)
{
int a = num/10;
int b = num%10;
IC_74hc595(giaima7doan[b]);
IC_74hc595(giaima7doan[a]);
}
void main()
{
set_tris_c(0x00);
while(TRUE)
{
for (int i=0; i<24;i++)
{
for (int j=0; i<60;j++)
{
for (int k=0; k<60;k++)
{
hienthi2so(k);
hienthi2so(j);
hienthi2so(i);
output_low(LATCH);
output_high(LATCH);
delay_ms(1000);
}
}
}
}
}







