Description
CNY70 Reflective Optical Sensor with Transistor Output – often used for line follower robots to detect a surface or a black line.

SOURCECODE
// ————————————————————————-
// CNY70ReadSerial
// Reads an analog input on pin 0, prints the result to the Serial Monitor.
// ————————————————————————-
// the setup routine runs once when you press reset:
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(100); // delay in between reads for stability
}
Determine the minimum and maximum treshold values and use these in the code to determine if f.i. a black line is stil under the sensor.




