const int potPin = A0;
int potVal = 0;
int led = 0;
void setup() {
Serial.begin(9600);
for(int x = 2; x < 8; x++){
pinMode(x, OUTPUT);
}
pinMode(potPin, INPUT);
}
void loop() {
potVal = analogRead(potPin);
Serial.print(potVal);
led = map(potVal, 0, 1023, 0, 6);
Serial.print(" ");
Serial.println(led);
if(led == 0){
for(int x = 2; x < 8; x++){
digitalWrite(x, LOW);
}
}
if(led == 1){
for(int x = 2; x < 8; x++){
digitalWrite(x, LOW);
}
digitalWrite(2, HIGH);
}
if(led == 2){
for(int x = 2; x < 8; x++){
digitalWrite(x, LOW);
}
for(int x = 2; x < 4; X++){
digitalWrite(x, HIGH);
}
}
if(led == 3){
for(int x = 2; x < 8; x++){
digitalWrite(x, LOW);
}
for(int x = 2; x < 5; X++){
digitalWrite(x, HIGH);
}
}
if(led == 4){
for(int x = 2; x < 8; x++){
digitalWrite(x, LOW);
}
for(int x = 2; x < 6; X++){
digitalWrite(x, HIGH);
}
}
if(led == 5){
for(int x = 2; x < 8; x++){
digitalWrite(x, LOW);
}
for(int x = 2; x < 7; X++){
digitalWrite(x, HIGH);
}
}
if(led == 6){
for(int x = 2; x < 8; x++){
digitalWrite(x, LOW);
}
for(int x = 2; x < 8; x++){
digitalWrite(x, HIGH);
}
}
}
Comments