🔄 Using setup() and loop() in Arduino
If you’re new to Arduino, the terms setup() and loop() will quickly become your best friends. These two functions form the backbone of every Arduino sketch, helping your board know what to do first and what to keep doing repeatedly.
🔹 What Is setup()?
The setup() function runs once when your Arduino starts. It’s the perfect place to:
- Initialize pins as input or output
- Start serial communication with your computer
- Set up sensors or devices
Think of it as your board’s “warm-up routine” before it starts doing the main work.
🔹 What Is loop()?
The loop() function runs continuously after setup() finishes. Anything inside loop() will repeat over and over. This is where your program reacts to sensors, updates outputs, and keeps your project running.
Examples of things you’d put in loop():
- Reading a button press
- Blinking an LED repeatedly
- Sending sensor data to the Serial Monitor
🚀 Getting Started
Try a simple “Blinker” sketch. Put your pin setup in setup() and make the LED turn on and off in loop(). It’s a classic beginner project that perfectly demonstrates how these functions work together.