Hello,
I have been following the 50$ robot tutorial and I have only the programming step left!
I added the Photovore_v1.c to source files under the AVR Studio, and followed the tutorial to the point of "Rebuild All"
At that point, I received 1 error and 3 warnings; the error being "expected identifier or '(' before while."
Here is the code that I copied and pasted in:
LED_off();//turn LED on
while(1)
{
//store sensor data
sensor_left=a2dConvert8bit(5);
sensor_right=a2dConvert8bit(4);
//detects more light on left side of robot
if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
{//go left
servo_left(44);
servo_right(44);
}
//detects more light on right side of robot
else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold)
{//go right
servo_left(25);
servo_right(25);
}
//light is about equal on both sides
else
{//go straight
servo_left(25);
servo_right(44);
}
/* Servo Test Code
i=250;
while(i>0)
{
servo_left(40);
i--;
}
i=250;
while(i>0)
{
servo_left(24);
i--;
}
*/
//rprintf("Initialization Complete\r\n");
//output message to serial (use hyperterminal)
//print("Hello, World! Read My Analog: %u\r\n", sensor_0);
delay_cycles(500);//a small delay to prevent crazy oscillations
}
My Intuition of my issue:
I have little knowledge of C; I am somewhat conversant in Python and Basic, I would think there must be "definitions" or parameters that I am missing. The code above is simply the bit that the downloaded Photovore_v1.c file shows to be added.
Any help is appreciated!
nfwill