Thank you for your attention.
I recently want hack the arduino robot to a actual useful thing, that is making it big and more powerful. My plan is to make it to a line follower and carry water for the people in working place.
I have changed the moter and moter driver chip to hold at least 5A.
The problem now is the optical sensor, in arduino robot, the sensor is CNY70, and can only applied very near to the ground(sensing distance is 0-10mm according the datasheet). The CNY70's output is anolog and feeded to a ADC of the moter board.
Now I want a optical sensor with a long sensing distance at least 10cm at compatible to arduino robot hardware interface. I searched the web and found there are optical sensor switches that can hold sensing distance of 10cm and the output is "digital".
What can I do? Is it can be used. I have not tried yet. Maybe should modify the libary code. Any suggestions, please.
Anyone, please give me some thoughts on it.
Now I want a optical sensor with a long sensing distance at least 10cm
Around 5cm will be all right for the case of tough ground.
What can I do with the optical sensor switch which only has two state - on/off ?
How can I modify the code?
// From lineFollow.cpp
void LineFollow::runLineFollow(){
for(int count=0; count<5; count++) // ---- Should judge based on the hardware
{
lectura_sensor[count]=map(_IRread(count),sensor_negro[count],sensor_blanco[count],0,127);
acu+=lectura_sensor[count];
}
//Serial.println(millis());
if (acu > NIVEL_PARA_LINEA)
{
acu/=5;
int error = ((lectura_sensor[0]<<6)+(lectura_sensor[1]<<5)-(lectura_sensor[3]<<5)-(lectura_sensor[4]<<6))/acu;
error = constrain(error,-100,100);
//Calculamos la correcion de velocidad mediante un filtro PD
int vel = (error * KP)/10 + (error-last_error)*KD;
last_error = error;
//Corregimos la velocidad de avance con el error de salida del filtro PD
int motor_left = constrain((robotSpeed + vel),-100,100); // --- robotSpeed // in percentage
int motor_right =constrain((robotSpeed - vel),-100,100);
//Movemos el robot
//motorsWritePct(motor_left,motor_right);
motorsWritePct(motor_left,motor_right);
//Esperamos un poquito a que el robot reaccione
delay(intergrationTime);
}
else
{
//Hemos encontrado una linea negra
//perpendicular a nuestro camino
//paramos el robot
motorsStop();
//y detenemos la ejecuci髇 del programa
//while(true);
reportActionDone();
//setMode(MODE_SIMPLE);
}
}
Hmm. IR transmitter/receiver pairs should work, although they may not have enough range. You could theoretically have a bogie out in front with the sensors closer to the ground.