just an FYI for all who read this...
This code below, when removing the LED_GO from the entire code will have the correct readings throughout with the same wiring. No removed parts from the board or disconnected wires.
const byte LED_PIN = 9; // the PWM pin the LED is attached to
// const byte LED_GO = 2;
const byte BTN1 = A1;
boolean START = false;
void setup() {
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);
// pinMode(LED_GO, OUTPUT);
pinMode(BTN1, INPUT);
}
void loop() {
if (digitalRead(BTN1) == HIGH)
{
// digitalWrite(LED_GO, HIGH);
START = true;
}
else {
// digitalWrite(LED_GO, LOW);
digitalWrite(LED_PIN, LOW);
START = false;
}
if (START)
{
// reads the input on analog pin A0 (value between 0 and 1023)
int analogValue = analogRead(A0);
// scales it to brightness (value between 0 and 255)
int brightness = map(analogValue, 0, 1023, 0, 255);
// sets the brightness LED that connects to pin 9
analogWrite(LED_PIN, brightness);
Serial.print("Analog: ");
Serial.print(analogValue);
Serial.print(", Brightness: ");
Serial.println(brightness);
delay(5);
}
}