Please help me, i want to change my analog value to a distance of cm reading for my ir sensor 4cm-30cm range
![]()
here is my code :-\
int sensorpin = 0; // analog pin used to connect the sharp sensor
int val = 0; // variable to store the values from sensor(initially zero)
void setup()
{
Serial.begin(9600); // starts the serial monitor
}
void loop()
{
val = analogRead(sensorpin); // reads the value of the sharp sensor
Serial.println(val); // prints the value of the sensor to the serial monitor
delay(600); // wait for this much time before printing next value
}
Thank you ![]()