@OP
1. This is what you have as your hardware setup.

2. Bring the wiper of the Pot at a position so that you get about 3.45V. Measure the voltage with DVM and record it.
3. Connect the wiper point with A0-pin of the UNO.
4. Now, work on paper to see which Led should be ON, and which one should be OFF.
(1) Input Dc voltage = 3.45V.
(2) The voltage of Step-4.1 will pass through the 10-bit ADC of UNO. We expect to get the following bit pattern:
(1023/5)*3.45 = 706 = 1011000010
But, the ADC has about 2-bit error; so, the last 2-bit could be 00 or 01 or 10 or 10. Let us forget these last 2 bits. Now, the Led condition would be:
LED9 LED8 LED7 LED6 LED5 LED4 LED3 LED2 LED1 LED0
ON OFF ON ON OFF OFF OFF OFF dont---care
4. Let us save the bit pattern of Step-2 into variable x by executing the following instruction:
unsigned int x = analogRead(A0);
5. Now, let us do the following tasks:
Read bit-0 of x and store it onto Dpin-2 (digitalWrite(2, bitRead(x, 0));
..................................................................................................
Read bit-9 of x and store it onto DPin-11 (bitWrite(PORTB, 3, bitRead(x, 9));
3. Upload the following sketch which is a modified version of your program (untested)
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
unsigned x = ananlogRead(A0);
for(int i=2, j=0; i<12, j<9; i+, j++)
{
digitalWrite(i, bitRead(x, j));
delay(100); //for stability
}
/*
for (int i = 2; i <= 11; i++) {
digitalWrite(i, HIGH);
delay(1 + analogRead(A0));
digitalWrite(i, LOW);
}
for (int i = 11; i >= 2; i--) {
digitalWrite(i, HIGH);
delay(1 + analogRead(A0));
digitalWrite(i, LOW);
}
*/
delay(2000); //for smoothness
}
4. Check that the states/statuses of Leds agree with your calculation.
5. Vary the Pot, measure the voltage, do the calculation and check that Led states changes correctly.
