int LED =13;
void setup()
{
pinMode(LED, OUTPUT);
}
void loop()
{
int distance = analogRead(0);
if ( distance > 2 )
{
digitalWrite(LED,LOW);
}
else
{
digitalWrite(LED,HIGH);
}
}
When I run this code the Led is on all the time but when I get in the 17inch and under it goes off. So how do I get it to read cm.