Hello I am very new to the arduino community. I have an arduino uno r3 and I am messing with a potensiomeeter and I want to make It that when the value of the potentiometer is lower the 256 the led light is turned of
int redled = 9; // the PWM pin the LED is attached to
int brightnessred = 0; // how bright the LED is
void setup() {
// declare pin 9 to be an output:
pinMode(redled, OUTPUT);
Serial.begin(9600);
}
void loop() {
// set the brightness of pin 9:
analogWrite(redled, brightnessred);
delay(30);
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);
if (sensorValue <= 256 || sensorValue >= 768) {
brightnessred = 7;
}
if (sensorValue > 256 && sensorValue < 768) {
brightnessred = 255;
}
}
and as you see in this line : brightnessred = 0;
brightnessred = 1; it wont work. I was wondering what the value of the brightnessred needs to be for the light to turn on and what it needs to be for it to turn off.