Hello, in college and having some difficulty with one problem. I have a SparkFun kit and im trying to do different tasks based on what value my potentiometer reads. How do I code, "If im not in the range of 257-512, then a light shouldnt go on."? Right now I am having the issue of the light turning on, but not turning off once I turn the knob outside of that range. Heres the snippet of my code I am having problems with.
while( 257 <= analogRead(A0) <= 512)
{
digitalWrite(11, HIGH);
}
if()// in the brackets, if analogRead(A0) is not in the range, then then digitalWrite(11,LOW)
Did some modifying. Once the dial reaches the second range, the light becomes red, but doesn't turn off if the dial is moved to another range. If i press the button attached to pin 7 to turn off the light, the light will remain off even if i move dial to another range. Also if you know any way I can use a for loop to replace the first if loop that's be greatly appreciated.