#include <Arduino.h>

// Pot outer legs to 5V/GND; wiper A0; onboard LED gives a coarse check.
// A0 is an analog input. The potentiometer wiper sends a variable voltage to this pin.
const int potPin = A0;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // Uno analogRead converts the input voltage into a number from roughly 0 to 1023.
  int raw = analogRead(potPin);
  // >= means at least. ? : turns the onboard LED on when the reading reaches the midpoint.
  digitalWrite(LED_BUILTIN, raw >= 512 ? HIGH : LOW);
  // Sample approximately every 50 ms instead of as fast as possible.
  delay(50);
}
