undefined reference to 'loop' (or 'setup')
- Arduino C++
You may see
Why it happens
void setup()orvoid loop()is missing or misspelt.- Only part of the code was copied.
How to fix it
- Copy the whole code block from the lesson with its Copy button.
- Check there's exactly one
void setup()and onevoid loop(), in small letters.
It worked if: Verify passes.
Tutorials where it can happen
- Arduino Sketch Structure: setup() and loop() Explained
- 16x2 LCD with Arduino: With and Without I2C
- 4-Digit 7-Segment Display with Arduino
- 8x8 LED Matrix with Arduino (No Driver IC)
- Air Quality and HVAC Control with Arduino, DHT11 and MQ-135
- Air Quality Monitor with Arduino, MQ-135 and LCD
108 more
- Alcohol Sensor MQ-3 with Arduino and LCD
- Aquarium Water Quality Monitor with Arduino
- Arduino Board - Pins Explained
- Arduino Breathalyzer with MQ-3 Alcohol Sensor and LCD
- Arduino Data Types and Variables, Simplified
- Arduino Functions: Write Your Own (Beginner Guide)
- Arduino Greenhouse: Temperature and Humidity Control with LCD
- Arduino LED Blink: the Simplest First Circuit
- Arduino Loops Explained: for and while
- Arduino Setup and Installation
- Automated Plant Watering System with LCD Feedback
- Automatic Blinds Control Based On Light Intensity
- Automatic LED Light with Arduino and LDR
- Automatic Pet Feeder with Arduino and Servo
- Automatic Plant Grow Light with Arduino and Relay
- Bluetooth Controlled Servo Motor using Arduino for Kids
- Building a Knock Sensor-Based Doorbell with LCD Display Using Arduino
- Building a Rainfall Measurement and LCD Display with Arduino
- Building a Smart Plant Watering System with Soil Moisture Sensor
- Building a Sound-Activated Alarm System with LCD Display
- Building a Sound-Activated Music Player with LCD Display
- Building a Vibration Sensor with LCD Feedback
- Building an Intruder Detection System with LCD and Alarm using Arduino
- Building Electronics Dice with LCD Display
- Capacitive Touch Sensor-Based Home Automation System with LCD Display
- CO Sensor-Based Ventilation Control System with LCD Output
- Coin-Operated Vending Machine with LCD Feedback
- Color Detection and Sorting System with TCS34725
- Colour Picker RGB LED with Arduino
- Creating a Touchless Hand Sanitizer Dispenser with LCD Display
- DHT11 Temperature and Humidity Sensor with Arduino
- Distance Measurement and Stepper Motor Control with LCD Output
- DIY Heart Rate Monitor with Pulse Sensor and LCD Display
- Fade and Blink an LED with Arduino (Code Explained)
- Fire Alarm with Arduino and KY-026 Flame Sensor
- Gas Leakage Detection and Solenoid Valve Control with Arduino
- Gas Sensor-Based Air Freshener System with LCD Display
- Gas Sensor-Based Garage Ventilation Control with LCD Display
- Gas Sensor-Based Smart Gas Meter with LCD Display
- Gesture-Controlled Light with Arduino and Ultrasonic Sensor
- Guide to Using SSD1306 Display with Arduino
- Hall Effect Sensor with Arduino: Measure Magnetic Field
- HC-SR04 Ultrasonic Sensor with Arduino Uno
- Heart Rate-Based Fitness Tracker with LCD Feedback
- Home Energy Monitor with Arduino
- Home Hydroponics System with Arduino
- Home Security Alarm with Arduino and PIR Sensor
- Home Security System with Motion Detection and LCD Feedback
- How to Fix HC-05 Upload Errors with SoftwareSerial
- How to Make a Smart Energy Meter with Arduino and LCD
- Human Presence Detection and Lighting Control with LCD Output
- LDR Light Meter with Arduino and LCD
- LED Bar Graph with Arduino
- Light Sensitive Blinds Control System with LCD Output
- Light-Sensitive Motorized Blinds with Arduino and LCD
- Light-Sensitive Plant Growth System with LCD Display
- Line Following Robot with LCD Display
- Liquid Level Detection and Pump Control
- LM35 Temperature Sensor with Arduino
- Mini Weather Station with Arduino, DHT11 and 16x2 LCD
- Motion-Activated Security Camera with LCD Feedback
- Motor Speed Control Based on Temperature with LCD Output
- MQ-2 Gas Sensor Arduino Code with I2C LCD
- Object Detection and Sorting System Using IR Sensors with LCD Feedback
- Object Tracking and Following System with LCD Feedback
- Obstacle Avoiding Robot Car with Arduino and LCD
- Obstacle-Avoiding Robot Arm with Arduino and LCD
- pH Level Monitoring and LCD Output with Arduino
- PIR Motion Sensor Alarm with Arduino (HC-SR501 and Buzzer)
- Plant Monitoring System with Arduino: Soil Moisture and DHT22
- Pool Water Quality Monitor with Arduino and pH Sensor
- Rain Sensor with Arduino
- Raindrop Detection and Automatic Wiper Control with LCD Output
- Rainwater Harvesting and Recharge: a Project for Kids
- Reading Analog Input with Arduino
- Reading RFID Tags with RC522 and Arduino
- Real-Time Power Usage Monitor with Arduino
- RFID Access Control with Arduino and LCD
- Smart Blinds Control Based on Weather Conditions with LCD Feedback
- Smart Mailbox with Arduino, Ultrasonic Sensor and Servo
- Smart Mirror with Arduino and LCD
- Smart Pet Door with Arduino, Ultrasonic Sensor and Servo
- Smart Traffic Light System with Arduino
- Smart Trash Can with Arduino: Lid Opens by Itself
- Smoke Detection and Exhaust Fan Control with LCD Display
- Smoke Detection and Fire Sprinkler Control with LCD Display
- Soil Moisture Monitoring and Irrigation System with Arduino Uno
- Soil Moisture Sensor for Farming with Arduino
- Soil Moisture-Based Plant Watering System with LCD Feedback
- Soil pH Level Monitoring and LCD Output
- Solar Power Monitor with Arduino and LCD
- Sound Level Meter with Arduino and LCD
- Sound-Activated LED Light Control with LCD Display
- SSD1306 0.96 inch OLED Display with Arduino (I2C)
- Temperature-Controlled Fan with Arduino and LM35
- Ultrasonic Parking Sensor with LCD Display using Arduino
- Ultrasonic Sensor and Servo Motor with Arduino Uno
- Using a Push Button in a Circuit
- UV Light Intensity Measurement and LCD Output
- Vehicle Parking Space Occupancy Detection with LCD Feedback
- Vehicle Speed Measurement and LCD Output Using Arduino
- Water Flow Measurement and Control with LCD using an Arduino
- Water Level Monitoring and Fish Tank Pump Control with Arduino
- Water Level Monitoring and Pump Control System with Arduino
- Water Level Monitoring and Solar Water Heater Control
- Water Quality Monitor with Arduino: pH and Turbidity
- Water Turbidity Measurement and LCD Output
- What is Arduino? Arduino Uno Basics Explained
Seen in a real run (some lines are close variants of it). Produced with Arduino CLI 1.5.1 and Arduino AVR core 1.8.8 (the same compiler the Arduino IDE uses).
Didn't help? Search another error or ask us.

