This small snippet of code uses an ultrasonic sensor to find the distance from an object. This distance is saved in Sensor1.
When it is below 25 cm, the LED should be bright. When it is below 70 cm and above 25cm, the LED should be dim, but not OFF.
Problem is it goes OFF between 25 and 70, rather than being dim. Suggestions?
#define ledpin A0
Sensor1 = distance;
if(Sensor1<25)
{analogWrite(ledpin,255);}
else if (Sensor1>25 && Sensor1<70)
{analogWrite(ledpin,175);}
else
{analogWrite(ledpin,0);}