#include<16f873a.h> #fuses HS,NOWDT,PUT,NOPROTECT,NOBROWNOUT #use delay(clock=20000000) #use fast_io(a) #use fast_io(b) #byte port_a=5 #byte port_b=6 //PIN_B2=前 //PIN_B3=右 //PIN_B1=左 //PIN_B0=後 //p1();p0(); //p1();p0();p0();p1(); //前↑ 後↑ 左↑ 右↑ //p0();p1(); //delay_ms(20); //この場合:右前 void p1(); void p0(); void main(){ int a; set_tris_a(0); set_tris_b(0xff); port_b_pullups(true); delay_ms(100); while(1){ if(PIN_B7||PIN_B0||PIN_B1||PIN_B6){//どれかのボタンが押された p1();p0(); if(PIN_B2) p1();//前 else p0(); if(PIN_B0) p1();//後 else p0(); if(PIN_B1) p1();//左 else p0(); if(PIN_B3) p1();//右 else p0(); p0();p1(); delay_ms(20); } //else } } void p1(){ int c; c=23; while(1){ port_a=0; delay_us(12); port_a=0x0f; delay_us(11); c=c-1; if(c==0) break; } } void p0(){ port_a=0x0f; delay_us(600); }