You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Ghost Source Code/************************************************************************//* EECE 474 Summer Semester 2002 *//************************************************************************//* *//* Team 1 Ghost Microcontroller Code *//* ================================= *//* *//* This program is for controlling the Ghost <strong>robot</strong>. It is designed for *//* a Microchip PIC16F877 running with an oscillator frequency of 4 MHz *//* It interfaces with the obstacle, Pac-Man contact, and Pac-Man beacon- *//* finding sensors. The Ghost estimates the position of Pac-Man using *//* the beacon-finding sensors and with knowledge of its current *//* position, uses a flood-filling maze-solving algorithm to find the *//* shortest path to get to Pac-Man. *//* *//************************************************************************/#include #include "Ghost.h"#device PIC16F877 *=16//#device adc=10#use delay (clock=4000000)#fuses XT, NOWDT, NOPROTECTint turn_counter = 0;int cell_step_counter = 0;int adjust_counter = 0;direction current_orient = N;short next_move_ready = 1;short turn_enable = 0;short turn_180 = 0;short stop = 1;short adjust_left = 0, adjust_right = 0;short backturn_dir = 0;short initial_start = 0;int calibration_stage = 0;int FRONT_OBSTACLE = 245;int MAX_RIGHT = 0;int MAX_LEFT = 0;int MIN_RIGHT = 0;int MIN_LEFT = 0;int MIDDLE_RIGHT = 0;int MIDDLE_LEFT = 0;short pacpos_unknown = 0;int maze[NUM_CELLS] ={NORTH | WEST,NORTH | SOUTH,NORTH,NORTH | SOUTH,NORTH | SOUTH,NORTH | EAST,WEST | EAST,WEST | NORTH,SOUTH,NORTH | SOUTH,NORTH | EAST,WEST | EAST,WEST | EAST,WEST | EAST,NORTH | WEST | SOUTH,NORTH,0,EAST,SOUTH,SOUTH,NORTH,EAST | SOUTH,WEST | EAST,WEST | EAST,NORTH | WEST,NORTH | SOUTH,0,NORTH | SOUTH,EAST | SOUTH,WEST | EAST,WEST | SOUTH,NORTH | SOUTH,SOUTH,NORTH | SOUTH,NORTH | SOUTH,EAST | SOUTH};// _ _ _ _ _ _ --> increasing x// | _ _ _ |// | | _ _ | |