int potPin = A0;
float potVal;
int potMap;
void setup() {
DDRD |= B11111111;
}
void loop() {
potVal = analogRead(potPin);
potMap = map(potVal, 0, 1024, 0, 8);
PIND |= B00000000;
PORTD |= B00000001 << potMap;
PORTD &= B01111111 >> potMap;
}