11.07.2015 Views

Builders guide robot pacman.pdf

Builders guide robot pacman.pdf

Builders guide robot pacman.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}else{}}rf_enable = 0;case S:case W:// move forwardnext_turn = NONE;break;// turn leftnext_turn = LEFT;break;// turn backwardsnext_turn = BACK;break;}current_orient = E;}else // south{switch (current_orient){case N:// turn backwardsnext_turn = BACK;break;case E:// turn rightnext_turn = RIGHT;break;case S:// move forwardnext_turn = NONE;break;case W:// turn leftnext_turn = LEFT;break;}current_orient = S;}if ( input(CONTACT) )stop = 1;elsestop = 0;if ( input(DOT_COUNT) ){output_bit(LCD_POINTS, 1);dot_count_timer = 1;}}main(){output_bit(LCD_RESET, 1);delay_ms(1);output_bit(LCD_RESET, 0);setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);// setup interruptsenable_interrupts(INT_TIMER1);enable_interrupts(INT_RB);enable_interrupts(GLOBAL);setup_port_a(ALL_ANALOG);setup_adc(adc_clock_internal);output_bit(L_WHEEL_DIR, L_FORWARD);output_bit(R_WHEEL_DIR, R_FORWARD);// initial direction forward// initial direction forwardoutput_bit(SENSOR_LED, 0);while( initial_start == 0 );for( ; ; ){read_obstacles( ob_left, ob_front, ob_right );if (ob_front > FRONT_OBSTACLE){stop = 1;// cell_counter = CELL_SIZE;}else{stop = 0;}if ( !turn_enable ){

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!