if (!input (pin_A4)) // look at motion sensor1
{ cw = 1; // set flag
// Code to move 45 degrees
for(i=0; i<15; i++){ //Counter for loop
output_high (PIN_B3); // 0000 1000 LED cw on
output_high (PIN_B4); // 0001 1000
delay_ms(25); // DELAY
output_low (PIN_B4); // 0000 1000
output_high (PIN_B5); // 0010 1000
delay_ms(25); // DELAY
output_low (PIN_B5); // 0000 1000
output_high (PIN_B6); // 0100 1000
delay_ms(25); // DELAY
output_low (PIN_B6); // 0000 1000
output_high (PIN_B7); // 1000 1000
delay_ms(25); // DELAY
output_low (PIN_B7); // 0000 1000
output_low (PIN_B3); // 0000 0000 LED cw off
}
do{
delay_ms(3000); //Stay
}
while (!input(pin_A4)); //Look at sensor1
for(i=0; i<15; i++){ // go home
output_high (PIN_B3); // 0000 1000 LED cw on
output_high (PIN_B7); // 1000 1000
delay_ms(25); // DELAY
output_low (PIN_B7); // 0000 1000
output_high(PIN_B6); // 0100 1000
delay_ms(25); // DELAY
output_low (PIN_B6); // 0000 1000
output_high (PIN_B5); // 0010 1000
delay_ms(25); // DELAY
output_low (PIN_B5); // 0000 1000
output_high (PIN_B4); // 0001 0000
delay_ms(25);
output_low (PIN_B4); // 0000 1000
output_low (PIN_B3); // 0000 0000 LED cw off
} // End for
} // End if for cw