คือผมพึ้งเริ่มต้นนะครับยังไม่เข้าใจ
ผมตองการ กด s1 ครั่งที่ 1 แล้วไฟวิ่งไปแล้วหยุด แล้วกด s1 อีดไฟวิ่งไป 1 ครั่ง แล้วหยุด กดอีก 1 ครั่งแล้วไฟวิ่งไปหยุด
มารอเริ่งใหม่
ทั่งหมด 3 ครั่ง
แต่ผมลองแล้วมัน วิ่งชุดแรกบ้าง ชุด สองบ้าง ไม่เป็น ขั้นตอนครับ
ท่านผู้รู้ช่วยหน่อยครับแก้ตรงใหนดีครับ
main()
{
TRISB = 0x00 ;
CMCON = 0x07 ;
TRISA = 0x01 ;
while(1)
{
while(PORTA.F0==1)
{
PORTB = 0x01;
Delay_ms(400);
PORTB = 0x00;
Delay_ms(500);
PORTB = 0X02;
Delay_ms(400);
PORTB = 0X00;
Delay_ms(500);
PORTB = 0x02;
Delay_ms(400);
PORTB = 0x00;
Delay_ms(500);
PORTB = 0x01;
Delay_ms(400);
PORTB = 0x00;
Delay_ms(500);
PORTB = 0x08;
Delay_ms(400);
PORTB = 0x00;
Delay_ms(500);
PORTB = 0x04;
Delay_ms(400);
PORTB = 0x00;
Delay_ms(500);
PORTB = 0X10;
Delay_ms(400);
PORTB = 0X00;
Delay_ms(500);
PORTB = 0x02;
Delay_ms(400);
PORTB = 0x00;
Delay_ms(500);
PORTB = 0x01;
Delay_ms(400);
PORTB = 0x00;
Delay_ms(500);
}
while(PORTA.F0==1)
{
PORTB = 0x01;
Delay_ms(2000);
PORTB = 0x00;
Delay_ms(1000);
PORTB = 0X20;
Delay_ms(2000);
PORTB = 0X00;
Delay_ms(1000);
PORTB = 0x03;
Delay_ms(2000);
PORTB = 0x00;
Delay_ms(1000);
PORTB = 0x01;
Delay_ms(2000);
PORTB = 0x00;
Delay_ms(1000);
}
while(PORTA.F0==1)
}
PORTB = 0x01;
Delay_ms(3000);
PORTB = 0x00;
Delay_ms(1000);
}
}
}