Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
//global variablesint sharp_IR_reading=0;int scan_thresh=0;//threshold value of scanning sensorint scan_angle=30;//position of scanner, in units of servo commandint max_scan_angle=56;//maximum position scanner can rotate to (57)//this function causes scanning servo to center on edge of objectvoid scan(void) { //lower (-) goes right //higher (+) goes left //30 far right, 50 straight, 56 far left (until it jams) /*psuedocode object is detected scan right object detected object not detected scan left until object detected*/ sharp_IR_reading=a2dConvert8bit(3); if (sharp_IR_reading > scan_thresh)//object detected { if (scan_angle>41) //overflow protection scan_angle-=2;//scan right } else //object not detected { if (scan_angle<=max_scan_angle) //maximum servo angle scan_angle+=2; //scan left //else //if scanned all the way, this forces it to start over // scan_angle=30; } //servo scan code servo_scan(scan_angle); }//automatically calculates threshold value before runvoid autocalibrate(void) { scan_thresh=a2dConvert8bit(3);//sensor reading }
scan(); //object on left if(scan_angle > 57) robot_turn_left(); //object on right else if(scan_angle < 41) robot_turn_right(); //object is centered else robot_go_straight(); delay_cycles(400);//a small delay to prevent crazy oscillations
void control(void) { scan(); }
void control(void) { while(1) { scan(); //object on left if(scan_angle < 570) {//go left wheel_left=800; wheel_right=800; }; //object on right else if(scan_angle > 1000) {//go right wheel_left=550; wheel_right=550; }; //object is centered else {//go straight wheel_left=800; wheel_right=550; } } }
/****************************************************************************** Copyright (c) 2008 www.societyofrobots.com* (please link back if you use this code!)** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License version 2 as* published by the Free Software Foundation.** Alternatively, this software may be distributed under the terms of BSD* license.*****************************************************************************///Add your code here//global variablesint sharp_IR_reading=0;int scan_thresh=30;//threshold value of scanning sensorint scan_angle=1000;//position of scanner, in units of servo commandint max_scan_angle=529;//maximum position scanner can rotate to (57)long int wheel_left=600;long int wheel_right=600;//this function causes scanning servo to center on edge of objectvoid scan(void) { //lower (-) goes right //higher (+) goes left //30 far right, 50 straight, 56 far left (until it jams) /*psuedocode object is detected scan right object detected object not detected scan left until object detected*/ sharp_IR_reading=a2dConvert8bit(3); if (sharp_IR_reading > scan_thresh)//object detected { if (scan_angle<529) //overflow protection scan_angle+=38;//scan right } else //object not detected { if (scan_angle<=max_scan_angle) //maximum servo angle scan_angle-=38; //scan left //else //if scanned all the way, this forces it to start over // scan_angle=30; } //servo scan code servo_scan(scan_angle); }void control(void) { while(1) { scan(); //object on left if(scan_angle < 570) {//go left wheel_left=800; wheel_right=800; } //object on right else if(scan_angle > 830) {//go right wheel_left=550; wheel_right=550; } //object is centered else {//go straight wheel_left=800; wheel_right=550; } } } //automatically calculates threshold value before runvoid autocalibrate(void) { scan_thresh=a2dConvert8bit(3);//sensor reading }
When I upoaded it, it said program succesful, verify succesful, CRC-error.So, I rebuilt the code, and tried uploading it again and got the same results. I changed the + and the - signs back, and everything uploaded fine. How does changing the + to a - mess up the uploading process?What is CRC?