segment


 

void main()

{

     TRISB = 0x07;   //0000 0111

     TRISA = 0;      //0000 0000

     PORTA=0x00;

     PORTB=0x00;

    while (1)

       { int i,u;


        if (PORTB.F0 == 0)

         {  for(i=0;i<=5;i++) {

                 PORTA.F0 = 1;

                 PORTA.F1 = 1;

                 PORTA.F2 = 0;

                 PORTB.F3 = 1;

                 PORTB.F4 = 1;

                 PORTB.F5 = 0;

                 PORTB.F6 = 1;Delay_ms(100);  }

                }


             if (PORTB.F1 == 0)

               { for(u=0;u<=5;u++)

                 {

                 PORTA = 0x06;            // 1

                 PORTB = 0x00;Delay_ms(500);

   // port B     PORTB = 0x5B;Delay_ms(3000);

                 PORTA = 0x03;            // 2

                 PORTB = 0x58;Delay_ms(500);

                 PORTA = 0x07;            // 3

                 PORTB = 0x48;Delay_ms(500);

                 PORTA = 0x06;            // 4

                 PORTB = 0x60;Delay_ms(500);

                 PORTA = 0x05;            // 5

                 PORTB = 0x68;Delay_ms(500);

                 PORTA = 0x05;            // 6

                 PORTB = 0x78;Delay_ms(500);

                 PORTA = 0x07;            // 7

                 PORTB = 0x00;Delay_ms(500);

                 PORTA = 0x07;            // 8

                 PORTB = 0x78;Delay_ms(500);

                 PORTA = 0x07;            // 9

                 PORTB = 0x68;Delay_ms(500);

                }

                 }

               if (PORTB.F2 == 0)

         {

                 PORTA = 0x06;            // 1

                 PORTB = 0x00;Delay_ms(500);

                 PORTA = 0x07;            // 3

                 PORTB = 0x48;Delay_ms(500);

                 PORTA = 0x05;            // 5

                 PORTB = 0x68;Delay_ms(500);

                 PORTA = 0x07;            // 7

                 PORTB = 0x00;Delay_ms(500);

                 PORTA = 0x07;            // 9

                 PORTB = 0x68;Delay_ms(500);

                }

                PORTA=0x00;

                PORTB=0x00;

      } }

ความคิดเห็น