ป้ายไฟ LED รูปแตงโมไม่มีเม็ด
Code
void main()
{
cmcon =0x07 ;
TRISA.F0 = 1;
TRISA.F1 = 1;
TRISA.F2 = 1;
PORTB =0;
TRISB = 0;
while (1)
{
if (PORTA.F0 == 0 )
{
PORTB.F0 = 1;
Delay_ms(150);
PORTB.F1 = 1;
Delay_ms(150);
PORTB.F2 = 1;
Delay_ms(150);
PORTB.F3 = 1;
Delay_ms(150);
PORTB.F4 = 1;
Delay_ms(150);
PORTB.F5 = 1;
Delay_ms(150);
PORTB.F6 = 1;
Delay_ms(150);
PORTB.F7 = 1;
Delay_ms(150);
PORTB = 0x00;
Delay_ms(50);
PORTB=0xFF;
Delay_ms(50);
PORTB = 0x00;
Delay_ms(50);
PORTB=0xFF;
Delay_ms(50);
PORTB=0;
Delay_ms(50);
}
if (PORTA.F1 == 0 )
{
PORTB.F1 = 1;
Delay_ms(150);
PORTB.F7 = 1;
Delay_ms(150);
PORTB.F6 = 1;
Delay_ms(150);
PORTB.F2 = 1;
Delay_ms(150);
PORTB.F5 = 1;
Delay_ms(150);
PORTB.F3 = 1;
Delay_ms(150);
PORTB.F2 = 1;
Delay_ms(150);
PORTB.F4 = 1;
Delay_ms(150);
PORTB = 0x00;
Delay_ms(50);
PORTB=0xFF;
Delay_ms(50);
PORTB = 0x00;
Delay_ms(50);
PORTB=0xFF;
Delay_ms(50);
PORTB=0;
Delay_ms(50);
}
if (PORTA.F2 == 0 )
{
PORTB.F7 = 1;
Delay_ms(150);
PORTB.F6 = 1;
Delay_ms(150);
PORTB.F5 = 1;
Delay_ms(150);
PORTB.F4 = 1;
Delay_ms(150);
PORTB.F3 = 1;
Delay_ms(150);
PORTB.F2 = 1;
Delay_ms(150);
PORTB.F1 = 1;
Delay_ms(150);
PORTB.F0 = 1;
Delay_ms(150);
PORTB = 0x00;
Delay_ms(50);
PORTB=0xFF;
Delay_ms(50);
PORTB = 0x00;
Delay_ms(50);
PORTB=0xFF;
Delay_ms(50);
PORTB=0;
Delay_ms(50);
}
}
}
ความคิดเห็น
แสดงความคิดเห็น