int potent01 = A0;
int potval01 = 0;
int potledr1 = 13;
int potledg1 = 12;
int potent02 = A1;
int potval02 = 0;
int potledr2 = 11;
int potledg2 = 10;
int potent03 = A2;
int potval03 = 0;
int potledr3 = 9;
int potledg3 = 8;
int ledblue = 7;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// initialize LED pins as OUTPUT:
pinMode(potledr1, OUTPUT);
pinMode(potledr2, OUTPUT);
pinMode(potledr3, OUTPUT);
pinMode(potledg1, OUTPUT);
pinMode(potledg2, OUTPUT);
pinMode(potledg3, OUTPUT);
pinMode(ledblue, OUTPUT);
}
void loop() {
potval01 = analogRead(potent01);
if (potval01 == 1023) {
// turn on the LED for max value
digitalWrite(potledr1, HIGH);
digitalWrite(ledblue, HIGH);
} else {
// turn off the LED for max value
digitalWrite(potledr1, LOW);
}
if (potval01 == 0) {
// turn on the LED for max value
digitalWrite(potledg1, HIGH);
} else {
// turn off the LED for max value
digitalWrite(potledg1, LOW);
}
potval02 = analogRead(potent02);
if (potval02 == 1023) {
// turn on the LED for max value
digitalWrite(potledr2, HIGH);
} else {
// turn off the LED for max value
digitalWrite(potledr2, LOW);
}
if (potval02 == 0) {
// turn on the LED for max value
digitalWrite(potledg2, HIGH);
} else {
// turn off the LED for max value
digitalWrite(potledg2, LOW);
}
potval03 = analogRead(potent03);
if (potval03 == 1023) {
// turn on the LED for max value
digitalWrite(potledr3, HIGH);
} else {
// turn off the LED for max value
digitalWrite(potledr3, LOW);
}
if (potval03 == 0) {
// turn on the LED for max value
digitalWrite(potledg3, HIGH);
} else {
// turn off the LED for max value
digitalWrite(potledg3, LOW);
}
// print out the values you read:
Serial.println(potval01);
Serial.println(potval02);
Serial.println(potval03);
delay(1); // delay in between reads for stability
}