#include /* Schema conectare LED+microsw */ #define YELLOW_LED_TRIS _TRISC13 #define GREEN_LED_TRIS _TRISC14 #define RED_LED_TRIS _TRISC15 #define lg _LATC13 #define lv _LATC14 #define lr _LATC15 /* The Switches and their ports */ #define SWITCH_S1_TRIS _TRISD8 #define SWITCH_S2_TRIS _TRISD9 #define s1 _RD8 #define s2 _RD9 _FGS(GWRP_OFF & GCP_OFF); _FOSCSEL(FNOSC_FRC); _FOSC(FCKSM_CSECMD & OSCIOFNC_ON & POSCMD_NONE); _FWDT(FWDTEN_OFF); int i,j; main (void) { for (;;) { _TRISD8=1; //sens s1 _TRISD9=1; // sens s2 _TRISC13= 0; _TRISC14= 0; _TRISC15= 0; _TRISB5=0; // sens comanda motor RB5 lv=1; lg=1; lr=1; _LATB5=1; if(s1==0) { // lg=0; lr=0; } if(s2==0) { lv=0; _LATB5=0; while(!s2); } } }