i was wondering if someone could take the time to show me the code for using the sensor data from a sharo ir range finder. I have everything hooked up on my robot and i can control the servos and make it moved in a preprogramed way, but i haven't figured out how to make the sensor do anything. (im using an axon controller if that helps)
there are 2 things id like to be able to do, and if i see the code for them i think i can figure everything else out
1)
I want to have the axon send the range that the ir sensor is perceiving through hyperterminal about once per second (not to fast) in inches or centimeters if possible.
2) I want to know how to get the range in cm or inches as a function so i can have somthing like
void control(void)
{
long unsigned int wheel_left=500;
long unsigned int wheel_right=500;
while(1)
{
if(sensor() > 20){
strait(100);
}
else
{
reverse(100);
}
}
void strait(int s)
{
for (count = 1; count <= s; count++){
wheel_left(1200);
wheel_right(200);
delay_ms(15);
}
}
void reverse(int rv)
{
for (count = 1; count <= rv; count++){
wheel_left(400);
wheel_right(1000);
delay_ms(15);
}
}
unsigned int sensor(void)
{
what would i put in here to have this return the value of the sensor (on the header pin 0 (axon controller top row, im not sure what its called header I think)
}
etc...
could this work and if so, how would i do the sensor data thing, i have no idea how to read the sensors, and i don't know if i need to define them in hardware.c or in the sensors.c, please any help would be very helpful thanks