Wiring
Check pinout, power supply, common GND and voltage levels before connecting the module.
Full code
const int sensorPin = A0;
const int ledPin = 13;
const int threshold = 500;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
int value = analogRead(sensorPin);
digitalWrite(ledPin, value > threshold ? HIGH : LOW);
Serial.println(value);
delay(100);
}How it works
This lesson matches the page title and gives a clean starting point for this exact example.
Common mistakes
Check board selection, wiring, libraries, power supply and serial monitor baud rate.