/******************************************************************* * Function: void initializeRobot(void) * Input Variables: none * Output Return: none * Overview: This initialize the robot by using other startups ********************************************************************/ void initializeRobot(void) { ATopstat = ATTINY_open();//open the tiny microcontroller LEopstat = LED_open(); //open the LED module LCopstat = LCD_open(); //open the LCD module STEPPER_open(); // Open STEPPER module for use SPKR_open(SPKR_TONE_MODE);//open the speaker in tone mode LED_open(); I2C_open(); ADC_open();//open the ADC module ADC_set_VREF( ADC_VREF_AVCC );// Set the Voltage Reference first so VREF=5V. // Initialize IR Values and Reset Prefilter checkIR(); prefilter(1); // Mistake? odometryTrigger = WORLD_RESOLUTION_SIZE*D_STEP which is about 6 odometryTrigger = WORLD_RESOLUTION_SIZE/2.75; // pixel array for the LCD screen for(int i = 0; i < 4; i++) { for(int j = 0; j < 32; j++) { pix_arr[i][j] = 0x00; } } }
void CBOT_main(void) { STEPPER_open(); // Enables control of the steppers ATTINY_open(); // Enables reading of the buttons SPKR_open(SPKR_BEEP_MODE); //enables beeping LCD_open(); // Enables use of the LCD ADC_open();//open the ADC module while(1) { if(ATTINY_get_SW_state(ATTINY_SW3)) { smartGoToGoal(4,4); } if(ATTINY_get_SW_state(ATTINY_SW4)) { wander('a'); } if (ATTINY_get_SW_state(ATTINY_SW5)) { char wall = 'l'; while(wall=='l'){ wall = wallFollow('l',4,5,10); } } //TODO:: Please write your application code } }
void CBOT_main( void ) { // Initialize variables int btnValue=0;//value of button pushed ATopstat = ATTINY_open();//open the tiny microcontroller LEopstat = LED_open(); //open the LED module LCopstat = LCD_open(); //open the LCD module STEPPER_open(); // Open STEPPER module for use SPKR_open(SPKR_BEEP_MODE);//open the speaker in beep mode LED_open(); I2C_open(); ADC_open();//open the ADC module ADC_set_VREF( ADC_VREF_AVCC );// Set the Voltage Reference first so VREF=5V. // Initialize IR Values and Reset Prefilter checkIR(); prefilter(1); // LCD_printf("PRESS a button\nOR\nWAIT for default\n"); //TMRSRVC_delay(3000);//wait 3 seconds //btnValue = WaitButton(); LCD_clear; // Infinite loop while (1) { // update the sensor values checkLightSensor(); checkIR(); checkContactIR(); //Test contact Sensors // LCD_printf("Right Contact: %i\nLeft Contact: %i\n\n\n",rightContact,leftContact); // TMRSRVC_delay(1000);//wait 1 seconds //Test IR Sensors // LCD_printf("FrontIR = %3.2f\nBackIR = %3.2f\nLeftIR = %3.2f\nRightIR = %3.2f\n", ftIR,bkIR,ltIR,rtIR); // TMRSRVC_delay(2000);//wait 2 seconds // run the moveBehavior FSM moveBehavior(LIGHT_LOVER); // debug primitive behaviors // moveAway(); // moveWall(); // moveRetreat(); // moveTrackLight(); // moveWander(); } }// end the CBOT_main()
void CBOT_main( void ) { // Initialize variables int btnValue=0;//value of button pushed int i=0;//loop counter BOOL ltContact;//left contact sensor BOOL rtContact;//right contact sensor float ltLght;//left light reading float rtLght;//right light reading unsigned char data; unsigned char pixel1 = 0; unsigned char pixel2 = 0; unsigned char pixel3 = 0; unsigned char pixel4 = 0; unsigned char pixel5 = 0; unsigned char pixel6 = 0; unsigned char pixel7 = 0; unsigned char pixel8 = 0; ATopstat = ATTINY_open();//open the tiny microcontroller LEopstat = LED_open(); //open the LED module LCopstat = LCD_open(); //open the LCD module STEPPER_open(); // Open STEPPER module for use. SPKR_open(SPKR_BEEP_MODE);//open the speaker in beep mode LED_open(); I2C_open(); ADC_open();//open the ADC module ADC_set_VREF( ADC_VREF_AVCC );// Set the Voltage Reference first so VREF=5V. btnValue = WaitButton(); // Infinite loop while (1) { // check sensors //checkIR(); // if no obstacle detected MOVE // if obstacle detected STOP // moveCollide(); moveAway(); } }// end the CBOT_main()
void CBOT_main( void ) { STEPPER_open(); // Open STEPPER module for use. // Move BOTH wheels forward and // make the robot move in a Figure 8. STEPPER_move_stwt( STEPPER_BOTH, STEPPER_FWD, 3341.106, 334.1106, 400, STEPPER_BRK_OFF, // Left STEPPER_FWD, 2305.88, 230.588, 400, STEPPER_BRK_OFF ); // Right STEPPER_move_stwt( STEPPER_BOTH, STEPPER_FWD, 2305.88, 230.588, 400, STEPPER_BRK_OFF, // Left STEPPER_FWD, 3341.106, 334.1106, 400, STEPPER_BRK_OFF ); // Right // Infinite loop! while( 1 ); }
void CBOT_main( void ) { // Initialize Robot ATopstat = ATTINY_open();//open the tiny microcontroller LEopstat = LED_open(); //open the LED module LCopstat = LCD_open(); //open the LCD module STEPPER_open(); // Open STEPPER module for use SPKR_open(SPKR_BEEP_MODE);//open the speaker in beep mode LED_open(); I2C_open(); ADC_open();//open the ADC module ADC_set_VREF( ADC_VREF_AVCC );// Set the Voltage Reference first so VREF=5V. // // Print a debug statement // LCD_printf("It's ALIVE\n\n\n\n"); // TMRSRVC_delay(3000);//wait 3 seconds // LCD_clear(); // Print the metric Map // printMetricMap(); // LCD_printf("%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n",ROBOT_METRIC_WORLD[0][0],ROBOT_METRIC_WORLD[0][1],ROBOT_METRIC_WORLD[0][2],ROBOT_METRIC_WORLD[0][3],ROBOT_METRIC_WORLD[1][0],ROBOT_METRIC_WORLD[1][1],ROBOT_METRIC_WORLD[1][2],ROBOT_METRIC_WORLD[1][3],ROBOT_METRIC_WORLD[2][0],ROBOT_METRIC_WORLD[2][1],ROBOT_METRIC_WORLD[2][2],ROBOT_METRIC_WORLD[2][3],ROBOT_METRIC_WORLD[3][0],ROBOT_METRIC_WORLD[3][1],ROBOT_METRIC_WORLD[3][2],ROBOT_METRIC_WORLD[3][3]); // TMRSRVC_delay(10000);//wait 10 seconds // wavefrontMake(); // LCD_printf("%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n",ROBOT_METRIC_WORLD[0][0],ROBOT_METRIC_WORLD[0][1],ROBOT_METRIC_WORLD[0][2],ROBOT_METRIC_WORLD[0][3],ROBOT_METRIC_WORLD[1][0],ROBOT_METRIC_WORLD[1][1],ROBOT_METRIC_WORLD[1][2],ROBOT_METRIC_WORLD[1][3],ROBOT_METRIC_WORLD[2][0],ROBOT_METRIC_WORLD[2][1],ROBOT_METRIC_WORLD[2][2],ROBOT_METRIC_WORLD[2][3],ROBOT_METRIC_WORLD[3][0],ROBOT_METRIC_WORLD[3][1],ROBOT_METRIC_WORLD[3][2],ROBOT_METRIC_WORLD[3][3]); // TMRSRVC_delay(10000);//wait 10 seconds // LCD_clear(); // Test the 4-Neighbor search // LCD_printf("%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n%i %i %i %i \n",ROBOT_METRIC_WORLD[0][0],ROBOT_METRIC_WORLD[0][1],ROBOT_METRIC_WORLD[0][2],ROBOT_METRIC_WORLD[0][3],ROBOT_METRIC_WORLD[1][0],ROBOT_METRIC_WORLD[1][1],ROBOT_METRIC_WORLD[1][2],ROBOT_METRIC_WORLD[1][3],ROBOT_METRIC_WORLD[2][0],ROBOT_METRIC_WORLD[2][1],ROBOT_METRIC_WORLD[2][2],ROBOT_METRIC_WORLD[2][3],ROBOT_METRIC_WORLD[3][0],ROBOT_METRIC_WORLD[3][1],ROBOT_METRIC_WORLD[3][2],ROBOT_METRIC_WORLD[3][3]); // TMRSRVC_delay(5000); // LCD_clear(); currentCellWorld = WORLD_CELL[0][0]; wavefrontMake(); while(currentCellWorld!=reachedEnd){ nextOrientation = fourNeighborSearch(currentCellWorld); metricMove(); moveMap(); currentCellWorld = shiftMap(currentCellWorld, currentMove, currentOrientation); } LCD_printf("LOOOOOOOOOOOOLZ"); TMRSRVC_delay(5000); LCD_clear(); // Unit test the function // sqrt function // int xDelta, yDelta; // float distance; // xDelta = abs(-3); // yDelta = abs(0); // distance = sqrt(((xDelta*xDelta)+(yDelta*yDelta))); // LCD_printf("xDel = %d\nyDel = %d\ndist = %f\n\n",xDelta,yDelta,distance); // TMRSRVC_delay(5000); // LCD_clear(); // cell values }// end the CBOT_main()