Professional Tutorial - From Basics to Practice
Beginner ~45 minOpen-source electronics platform based on easy-to-use hardware and software, designed for creating interactive electronic projects.
💡 Did you know? Arduino was created in 2005 in Italy to help students learn electronics without expensive equipment!
| Component | Specification |
|---|---|
| Microcontroller | ATmega328P |
| Operating Voltage | 5V |
| Input Voltage | 7-12V (recommended) |
| Digital I/O Pins | 14 (6 with PWM capability) |
| Analog Input Pins | 6 (A0-A5) |
| Flash Memory | 32 KB |
| SRAM | 2 KB |
| Clock Speed | 16 MHz |
Pins with PWM capability (marked with ~):
These pins can produce analog-like output using Pulse Width Modulation
A solderless prototyping board that allows you to build and test circuits without permanent connections.
💡 Pro Tip: Use color-coded wires - Red for power (+), Black for ground (-), other colors for signals
Long leg = Anode (+) → Connects to resistor
Short leg = Cathode (-) → Connects to ground
If connected backwards, the LED won't light up!
setup(): Runs once when Arduino starts. Initialize pins, serial communication, and variables.
loop(): Runs continuously after setup. Contains main program logic.
pinMode(pin, OUTPUT) - Configure pindigitalWrite(pin, HIGH/LOW) - Turn on/offdelay(ms) - Pause executionSerial.begin(9600) - Start serialSerial.println() - Print to monitor🎯 Expected Result: The LED will blink ON for 1 second, then OFF for 1 second, repeating continuously. Serial Monitor will display "LED ON" and "LED OFF" messages.
💡 Note: No external resistor needed for button - we use Arduino's internal pull-up resistor!
⚙️ How it works:
• Button pressed = LOW signal
• Button released = HIGH signal (pull-up)
LED turns ON when button is pressed, OFF when released - creating an interactive circuit controlled by user input!
The INPUT_PULLUP mode enables an internal resistor (20-50kΩ) that pulls the pin to HIGH (5V) when the button is not pressed.
When you press the button, it connects the pin to ground (GND), making it read LOW.
if (buttonState == LOW)
🎯 Expected Result: LED lights up immediately when you press the button and turns off when you release it. Serial Monitor shows real-time button state.
Pulse Width Modulation (PWM) allows us to simulate analog output on digital pins by rapidly switching between HIGH and LOW.
0 = Completely OFF (0% duty cycle)
64 = 25% brightness
128 = 50% brightness
192 = 75% brightness
255 = Full brightness (100% duty cycle)
Only these pins can use analogWrite():
Look for the ~ symbol next to the pin number on the board!
⚡ How PWM Works: The pin rapidly switches on and off. A higher value means more "on" time, making the LED appear brighter. The switching happens so fast (490 Hz) that our eyes perceive it as varying brightness!
pinMode(pin, OUTPUT)
Configure pin as output
digitalWrite(pin, HIGH/LOW)
Set digital pin to 5V (HIGH) or 0V (LOW)
analogWrite(pin, 0-255)
PWM output with duty cycle 0-255
pinMode(pin, INPUT_PULLUP)
Configure pin as input with internal pull-up
digitalRead(pin)
Read digital value: HIGH or LOW
analogRead(pin)
Read analog value: 0-1023 (10-bit ADC)
delay(milliseconds)
Pause program for specified time
millis()
Returns time (ms) since program started
delayMicroseconds(us)
Microsecond-precision delays
Serial.begin(9600)
Initialize serial at 9600 baud rate
Serial.println(data)
Print data with newline
Serial.print(data)
Print data without newline
LED Not Working?
Button Not Responding?
Challenge 1: Traffic Light System
Build a 3-LED traffic light (Red, Yellow, Green) that cycles through proper sequences: Red (5s) → Yellow (2s) → Green (5s) → Yellow (2s)
Challenge 2: Multi-Level Brightness
Use a button to cycle through 4 brightness levels: OFF → DIM (64) → MEDIUM (128) → BRIGHT (255)
Challenge 3: Reaction Timer Game
LED lights up after random delay. Measure how fast user presses button using millis()
Continue your Arduino journey at arduino.cc
Happy Making! ✨