int main(void) { // initialize the device SYSTEM_Initialize(); //Light show debounce(2); PORTAbits.RA3 = 0; //Led 4 debounce(5); PORTBbits.RB5 = 0; //Led 3 debounce(2); PORTBbits.RB7 = 0; //Led 2 debounce(1); PORTBbits.RB6 = 0; //Led 1 debounce(1); ResetMemory(); while (1) { //All mighty while loop if(TransmitComplete){ TransmitComplete = 0; SetTo90(); if(LocalMemory[0]== 0x01){ MoveServo1_Degrees(LocalMemory[1]); debounce(1); MoveServo4_Degrees(LocalMemory[4]); debounce(1); MoveServo3_Degrees(LocalMemory[3]); debounce(1); MoveServo2_Degrees(LocalMemory[2]); debounce(1); MoveServo5_Degrees(LocalMemory[5]); ResetMemory(); } else if(LocalMemory[0]== 0x02){ switch(LocalMemory[1]){ case 1: GrabBlock(); break; case 2: break; case 3: break; case 4: break; case 5: break; } } } if(PORTAbits.RA0 == 1){ //S1 pressed S1++; if(S1==10) //Overflow Condition~No State 9 S1 = 1; debounce(10); StateMaker(S1); //Set the LEDs } if(PORTAbits.RA2 == 1){ //S2 pressed PORTBbits.RB6 = 1; //Signifies selection with blinking of light debounce(5); PORTBbits.RB6 = 0; debounce(3); PORTBbits.RB6 = 1; debounce(2); PORTBbits.RB6 = 0; debounce(1); PORTBbits.RB6 = 1; MakeSelection(S1); PORTBbits.RB6 = 1; //Signifies end of selection with blinking of light debounce(5); PORTBbits.RB6 = 0; debounce(3); PORTBbits.RB6 = 1; debounce(2); PORTBbits.RB6 = 0; debounce(1); PORTBbits.RB6 = 1; debounce(1); PORTBbits.RB6 = 0; } } return -1; }
/* Main application */ int main(void) { // initialize the device SYSTEM_Initialize(); TimerVariable = 0; int SwitchCount = 1; LATAbits.LATA3 = 0; OneMsDelay(50); LATBbits.LATB7 = 0; OneMsDelay(20); LATBbits.LATB6 = 0; OneMsDelay(30); LATBbits.LATB5 = 0; OneMsDelay(100); int Temp; while (1) { // Add your application code if(TransmitComplete) { TransmitComplete = 0; if(LocalMemory[0]== 0x00) { } else if(LocalMemory[0] != 0x00) { switch(LocalMemory[0]) { case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; } } } if(PORTAbits.RA2 == 1) { TimerVariable = 0; while(PORTAbits.RA2 == 1); Temp = TimerVariable; if(Temp > 1000) { SelectionMaker(SwitchCount); } else { SwitchCount++; if(SwitchCount>=5) SwitchCount = 1; StateMaker(SwitchCount); } OneMsDelay(500); } LATBbits.LATB7 = 1; OneMsDelay(50); LATBbits.LATB7 = 0; OneMsDelay(10); } return -1; }