Getting Started: First Sketch to First Project
Anatomy of a Sketch
void setup() { // runs once at power-on/reset } void loop() { // runs repeatedly, forever, after setup() }Every Arduino program has exactly these two functions. setup() is where you configure pin modes, start serial communication, initialize sensors. loop() is where the actual ongoing behavior lives — it runs continuously until power is cut.
Your First Real Circuit: Button-Controlled LED
- LED + 220Ω resistor from pin 13 to GND
- Push button from pin 2 to GND, with the pin's internal pull-up resistor enabled in software (no external resistor needed)
Reading the Serial Monitor
Add Serial.begin(9600); in setup(), then Serial.println(someValue); anywhere in loop() to print debug output. Open Tools > Serial Monitor (or the icon top-right) and make sure its baud rate dropdown matches what you set in Serial.begin() — mismatched baud rate is the most common reason people see garbage characters instead of readable text.
Analog Input Basics
analogRead(A0) returns 0-1023 representing 0-5V (or 0-3.3V on 3.3V boards) on that analog pin — this is how you read potentiometers, light sensors (LDRs), and most analog sensors.
PWM "Fake Analog" Output
Digital pins marked with a ~ on the board silkscreen support analogWrite(pin, value) where value is 0-255 — this isn't a true analog voltage, it's a fast on/off pulse (PWM) that averages out to look analog to LEDs (brightness), motors (speed via a driver), and most things that respond to average power rather than instantaneous voltage.
Where to Go Next
Once button+LED and analog read both make sense, you have the two fundamental I/O patterns nearly every Arduino project builds on. From here: try combining them (analog input controlling PWM output — a potentiometer dimming an LED), then move on to a real sensor (DHT22 temp/humidity is a forgiving first "real" sensor to add).
Related Guides
- Getting Started with ESP32: GPIO, WiFi, and Your First Project
- From Download to First Print: Complete Beginner Workflow
- Arduino vs ESP32: Which Should You Use? A Practical Comparison
- Getting Started with Flipper Zero: The Complete Beginner Guide
- Arduino IDE Setup & Board Manager Guide
- How to Program Addressable LED Strips: WS2812B Patterns, Effects, and Power Design
- How to Use the ESP32-CAM: Video Streaming, Motion Detection, and Time-Lapse
- I2C vs SPI vs UART: How to Choose and Use Serial Communication Protocols