I'm new to the Arduino (I have Arduino Uno) and recently was playing around with analogWrite. I set up two potentiometers and two LEDs (both LEDs attached to PWM pins). However, when I have only one potentiometer attached it controls both LEDs. I do not understand why this is happening since the LEDs rely on different potentiometers that are attached to different analog pins. Why is this happening?
#define LED1 5
#define LED2 6
#define POT1 A0
#define POT2 A1
int val1, val2;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
}
void loop() {
val1 = analogRead(POT1);
val2 = analogRead(POT2);
analogWrite(LED1, val1);
analogWrite(LED2, val2);
}