Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main(void) {
- unsigned int read;
- InitializeSystem();
- for(;;) {
- read = getAD1();
- if(read > 150) { // No wall detected, move forwards!
- PORTEbits.RE0 = 1;
- PORTEbits.RE1 = 1;
- PORTB = 0b10001001;
- CCPR2L = 128;
- CCPR1L = 128;
- } else { // Wall detected, move backwards!
- PORTEbits.RE0 = 0;
- PORTEbits.RE1 = 0;
- PORTB = 0b00000001;
- CCPR2L = 128;
- CCPR1L = 128;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment