2 LED's one pot Arduino
Trying to control 2 LED's with one pot, I want one led to turn on only in one certain point of the pot and the other to remain on while in all other positions. So far the best I can come up with is something like this but im not sure how to modify for just two LED's and the specifics above. Am I on the right track or can someone help me please. byte ledPin[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; //pins used for LED's int potPin = 0; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin void setup() { for(int i = 0; i < 13; i++){ pinMode(ledPin[i],OUTPUT); } } void loop() { val = analogRead(potPin); // reads the value of the potentiometer (value between 0 and 1023) for (int i = 0; i < 13; i++) { if( (i * 102) > val) { digitalWrite(ledPin[i], HIGH);} else { digitalWrite(ledPin[i], LOW);} } }