โครงงานที่13 วงจรเครื่องตั้งเวลา

code

 int conv7segment(int number);
 main()
 {
 int minute,sec;
 TRISB = 0x00;
 TRISA = 0x00;
 CMCON = 0x07;
 PORTA.F0=0;
 PORTA.F1=1;
  for (minute=9;minute>0;minute--)
  {
   PORTB = conv7segment(minute);
  for (sec=0;sec<=59;sec++)
  {
    PORTB.F7=1;
    Delay_ms(100);
    PORTB.F7=0;
    Delay_ms(100);
    }
 }
  PORTB = conv7segment(0);
  PORTA.F0=1;
  PORTA.F1=0;
  }
int conv7segment(int number)
{
 switch (number)
 {
 case 1: return 0x06;
 case 2: return 0x5b;
 case 3: return 0x4f;
 case 4: return 0x66;
 case 5: return 0x6d;
 case 6: return 0x7d;
 case 7: return 0x07;
 case 8: return 0x7f;
 case 9: return 0x6f;
 case 0: return 0x3f;
 }
 }

ความคิดเห็น

บทความที่ได้รับความนิยม