Complete Arduino Beginner Notes — Fully
Explained & Project-Ready
1. What is Arduino?
Arduino is an open-source electronics platform that makes building hardware projects
simple. It consists of:
• Hardware: Arduino boards (e.g., UNO, Nano) with microcontrollers.
• Software: Arduino IDE to write, upload, and debug code.
With Arduino, you can create robots, smart sensors, alarms, IoT devices, and much more by
connecting inputs, outputs, and writing basic code.
2. Arduino Hardware Breakdown
Microcontroller:
• The "brain" of the board (e.g., ATmega328P on Arduino UNO).
• Executes code, processes inputs, and controls outputs.
Digital I/O Pins (0–13):
• Can be set as INPUT or OUTPUT.
• HIGH = 5V, LOW = 0V.
Analog Pins (A0–A5):
• Read analog values (0–1023) from sensors like LDRs and potentiometers.
PWM Pins (~):
• Fake analog output using fast pulses (used in motors, LED dimming).
• Use analogWrite() with values from 0–255.
Special Communication Pins:
• I2C: A4 (SDA) and A5 (SCL) — for modules like OLED, RTC.
• SPI: Pins 10, 11, 12, 13 — for SD cards, displays.
• UART/Serial: Pins 0 (RX) and 1 (TX) — for Serial Communication.
Power Pins:
• 5V / 3.3V: For powering components.
• GND: Ground pins (must complete the circuit).
USB Port:
• Upload code + provide power from PC.
DC Jack:
• Plug in external power (7–12V recommended).
Crystal Oscillator (16MHz):
• Keeps time for precise operations.
Reset Button:
• Restarts your sketch from the beginning.
Additional Protections:
• Voltage regulators and polyfuses prevent board damage from overvoltage.
3. Arduino Software (IDE)
Arduino IDE:
• Free app to write/upload code.
• Key features: Code editor, upload/verify buttons, Serial Monitor, and basic error
reporting.
Advanced Software Tools:
• PlatformIO (VSCode Extension): For pro-level Arduino coding.
• Arduino CLI: Command-line interface to automate uploads/builds.
Code Structure:
void setup() {
// runs once
}
void loop() {
// runs forever
4. Core Commands & Functions
Function Description
Set pin mode: INPUT, OUTPUT,
pinMode(pin, mode)
INPUT_PULLUP
digitalWrite(pin, HIGH/LOW) Send 5V (HIGH) or 0V (LOW)
digitalRead(pin) Read HIGH/LOW from pin
analogRead(pin) Get value (0–1023) from analog pin
analogWrite(pin, value) PWM output (0–255)
delay(ms) Pause (ms = milliseconds)
[Link](9600) Start Serial Monitor
[Link]()/println() Print data to monitor
map(value, fromLow, fromHigh, toLow,
Remap sensor values to usable range
toHigh)
Mapping Example:
int sensorVal = analogRead(A0);
int outputVal = map(sensorVal, 0, 1023, 0, 255);
analogWrite(9, outputVal);
5. Example Code: Blink LED
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // ON
delay(1000); // Wait 1 sec
digitalWrite(13, LOW); // OFF
delay(1000);
6. Variables & Data Types
int ledPin = 13;
float temp = 25.3;
bool isOn = true;
char grade = 'A';
String name = "Arduino";
7. Conditionals & Loops
if-else:
if (temp > 30) {
digitalWrite(fanPin, HIGH);
} else {
digitalWrite(fanPin, LOW);
for loop:
for (int i = 0; i < 5; i++) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
while loop:
int count = 0;
while (count < 5) {
[Link](count);
count++;
8. Reading Sensor Data
Digital Sensor (e.g., Button, IR):
int irPin = 2;
void setup() {
pinMode(irPin, INPUT);
[Link](9600);
void loop() {
int val = digitalRead(irPin);
[Link](val);
delay(100);
Analog Sensor (e.g., LDR):
int ldrPin = A0;
void setup() {
[Link](9600);
}
void loop() {
int light = analogRead(ldrPin);
[Link](light);
delay(100);
Temperature Sensor (DHT11):
#include <DHT.h>
DHT dht(2, DHT11);
void setup() {
[Link](9600);
[Link]();
void loop() {
float t = [Link]();
float h = [Link]();
[Link]("Temp: "); [Link](t);
[Link](" Humidity: "); [Link](h);
delay(2000);
9. Serial Monitor
void setup() {
[Link](9600);
}
void loop() {
int sensorVal = analogRead(A0);
[Link]("Value: ");
[Link](sensorVal);
delay(1000);
Use this to debug your code or see live sensor values.
10. Using Libraries
Libraries help you work with sensors/modules easily.
#include <DHT.h>
DHT dht(2, DHT11);
void setup() {
[Link]();
void loop() {
[Link]([Link]());
delay(1000);
Add libraries via:
Sketch > Include Library > Manage Libraries
Popular libraries to know:
• Adafruit Sensor
• LiquidCrystal (LCD displays)
• Wire (I2C communication)
• SPI (SPI devices)
11. Uploading Code
• Click the Upload button in the IDE.
• Code is compiled and sent to Arduino.
• Stored in its internal flash memory.
Error Handling Tips:
• Check board and COM port settings.
• Restart Arduino IDE if upload fails.
• Press Reset button if necessary.
12. Code Writing Tips
Use clear variable names
Add comments (//) to explain steps
Break complex logic into small functions
Always test with Serial Monitor
Organize code using multiple tabs (files)
13. Arduino Code Flow
setup() --> runs once
loop() --> runs repeatedly
14. Arduino’s Core Concept
Input Device (Sensor)
Arduino (Processes Code)
↓
Output Device (LED, Motor, Buzzer)
You’re now ready to build real-world electronic projects! Start small — blinking LEDs,
reading LDRs, making a temperature monitor — and level up to automation, IoT, and even AI
+ Arduino!