Hello All! First off i would like to apologies for my previous post not being up to scratch. So basically, i have an LED circuit of which a potentiometer, when moved to the left or right, will toggle an led to light up. So if the arduino reads a voltage from the potentiometer of lets say 5V(Fully Right), it sets D12 to a HIGH, with the other 11 LEDS off, and if it reads 0 valts(Fully Left), it sets D0 to a HIGH, and so on and so fourth.
I was successful in creating this code, but the problem is that it only uses a very small amount of the potentiometer (10K Ohm) and 3 quarters of the potentiometer just leaves all leds off. I have attempted changing the map value to one that is higher, i have also attempted researching and asking a good friend of mine for help, but he suggested that i post it here.
Here is my code-
int FDOT = 0;
int FULL = 1;
int F2 = 2;
int F28 = 3;
int F4 = 4;
int F56 = 5;
int F8 = 6;
int F11 = 7;
int F16 = 8;
int F22 = 12;
int CDOT = 10;
int CLEAR = 11;
int potPin = A0;
int potVal;
float voltage;
void setup() {
pinMode(FDOT, OUTPUT);
pinMode(FULL, OUTPUT);
pinMode(F2, OUTPUT);
pinMode(F28, OUTPUT);
pinMode(F4, OUTPUT);
pinMode(F56, OUTPUT);
pinMode(F8, OUTPUT);
pinMode(F11, OUTPUT);
pinMode(F16, OUTPUT);
pinMode(F22, OUTPUT);
pinMode(CDOT, OUTPUT);
pinMode(CLEAR, OUTPUT);
pinMode(potPin, INPUT);
}
void loop() {
potVal = analogRead(A0);
analogRead(potPin);
potVal = map(potVal, 0, 1023, 0, 11);
voltage = potVal * (5.0 / 1023);
if (analogRead(potVal) == 0) // FDOT CODE
digitalWrite(FDOT, HIGH);
else
digitalWrite(FDOT, LOW); // FDOT CODE END
if (analogRead(potVal) == 1) // FULL CODE
digitalWrite(FULL, HIGH);
else
digitalWrite(FULL, LOW); // END OF FULL CODE
if (analogRead(potVal) == 2) // F2 CODE
digitalWrite(F2, HIGH);
else
digitalWrite(F2, LOW); // END OF F2 CODE
if (analogRead(potVal) == 3) // F28 CODE
digitalWrite(F28, HIGH);
else
digitalWrite(F28, LOW); // END OF F28 CODE
if (analogRead(potVal) == 4) // F4 CODE
digitalWrite(F4, HIGH);
else
digitalWrite(F4, LOW); // END OF F4 CODE
if (analogRead(potVal) == 5) // F56 CODE
digitalWrite(F56, HIGH);
else
digitalWrite(F56, LOW); // END OF F56 CODE
if (analogRead(potVal) == 6) // F8 CODE
digitalWrite(F8, HIGH);
else
digitalWrite(F8, LOW); // END OF F8 CODE
if (analogRead(potVal) == 7) // F11 CODE
digitalWrite(F11, HIGH);
else
digitalWrite(F11, LOW); // END OF F11 CODE
if (analogRead(potVal) == 8) // F16 CODE
digitalWrite(F16, HIGH);
else
digitalWrite(F16, LOW); // END OF F16 CODE
if (analogRead(potVal) == 9) // F22 CODE
digitalWrite(F22, HIGH);
else
digitalWrite(F22, LOW); // END OF F22 CODE
if (analogRead(potVal) == 10) // CDOT CODE
digitalWrite(CDOT, HIGH);
else
digitalWrite(CDOT, LOW); // END OF CDOT CODE
if (analogRead(potVal) == 11) // CLEAR CODE
digitalWrite(CLEAR, HIGH);
else
digitalWrite(CLEAR, LOW); // END OF CLEAR CODE
}
And here is a video better explaining what i mean.