AnuElectronics.com

Arduino Starter Kit
Complete Tutorial

A world-class step-by-step guide for students, makers & engineers — from your first blink to real-world automation projects.

Arduino Uno R3
šŸ”§ Beginner Friendly šŸ’” 15+ Components šŸ› ļø 5 Real Projects šŸ“Ÿ Displays & Sensors šŸ  Home Automation āš™ļø Motors

Published by AnuElectronics.com Ā· Arduino Starter Kit Series

Introduction › What is Arduino?
šŸ“–

Introduction to Arduino

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It consists of microcontroller boards that can be programmed to read inputs from sensors and control outputs like lights and motors. It is widely used for DIY projects, prototyping, robotics, and home automation.

⭐ Why Arduino?

šŸ’ø Inexpensive

Low-cost boards accessible to students and hobbyists worldwide.

šŸ–„ļø Cross-Platform

Works on Windows, macOS, and Linux.

🧩 Simple IDE

Beginner-friendly environment with rich library support.

šŸ”“ Open Source

Both hardware and software are fully open source.

šŸŒ Large Community

Millions of users, tutorials, and libraries available online.

⚔ Fast Prototyping

Go from idea to working prototype in minutes.

šŸ› ļø Common Applications

šŸ¤–Robotics
šŸ Home Automation
šŸ“”IoT Devices
šŸŽ“Education
šŸ”¬Prototyping
🌱Smart Agriculture
Introduction › Arduino Uno R3
šŸ”Œ

Arduino Uno R4 Board

The Arduino Uno R3 is based on the ATmega328P microcontroller. It is the most widely used board for education and prototyping. It comes in DIP (easy to replace chip) and SMD (compact surface-mount) variants.

šŸ“Š Key Specifications

Feature Value
Microcontroller ATmega328P
Operating Voltage 5V
Input Voltage (Recommended) 7–12V
Digital I/O Pins 14 (6 PWM outputs ~)
Analog Input Pins 6 (A0–A5)
DC Current per I/O Pin 40 mA
Flash Memory 32 KB (0.5 KB bootloader)
SRAM 2 KB
EEPROM 1 KB
Clock Speed 16 MHz

šŸ“Œ Pin Descriptions

Pins 0(RX) & 1(TX)

Serial communication — receive and transmit TTL data.

Pins 2 & 3 (INT)

External interrupts — trigger on LOW, rising/falling edge.

Pins ~3,5,6,9,10,11

PWM output — 8-bit (0–255).

Pins 10–13 (SPI)

SPI: SS, MOSI, MISO, SCK.

Pin 13 (Built-in LED)

Onboard LED connected to digital pin 13.

A0–A5 (Analog)

10-bit ADC: reads 0–1023.

A4(SDA) & A5(SCL)

I2C / TWI communication.

RESET

Pull LOW to reset the microcontroller.

Introduction › Arduino IDE Setup
šŸ’»

Setting Up Arduino IDE

The Arduino IDE is a free tool to write sketches and upload them to your board. Download from arduino.cc/en/software.

šŸ“„ Installation Steps

  • 1
    Download

    Visit arduino.cc, select your OS (Windows/macOS/Linux), download installer.

  • 2
    Windows

    Run .exe installer, follow wizard, accept license, install all components, click Finish.

  • 3
    macOS

    Open .dmg file, drag Arduino to Applications folder, launch from Applications.

  • 4
    Linux

    Extract archive, open terminal in folder, run: sudo ./install.sh

āœ…

Tip: Install Arduino IDE 2.x for auto-complete, syntax highlighting, and integrated Serial Plotter.

Introduction › Programming Basics
šŸ§‘ā€šŸ’»

Arduino Programming Basics

Arduino programs are called sketches written in C/C++. Every sketch must have two core functions:

Basic Sketch Structure
const int LED_PIN = 13;

void setup() {
  pinMode(LED_PIN, OUTPUT);  // Runs ONCE on power-up
  Serial.begin(9600);
}

void loop() {
  digitalWrite(LED_PIN, HIGH); // Runs FOREVER
  delay(1000);
  digitalWrite(LED_PIN, LOW);
  delay(1000);
}

šŸ“š Essential Functions

Function Description Example
pinMode(pin, mode) Set pin as INPUT/OUTPUT pinMode(8, OUTPUT);
digitalWrite(pin, val) Write HIGH/LOW to digital pin digitalWrite(8, HIGH);
digitalRead(pin) Read HIGH/LOW from pin int v = digitalRead(2);
analogRead(pin) Read 0–1023 from A0–A5 int v = analogRead(A0);
analogWrite(pin, val) PWM output 0–255 analogWrite(9, 128);
delay(ms) Pause for milliseconds delay(500);
Serial.println(val) Print to Serial Monitor Serial.println(temp);
tone(pin, freq) Generate audio frequency tone(3, 1000);
map(val,fL,fH,tL,tH) Re-map value from one range to another map(val,0,1023,0,180);
Introduction › Board Bring-Up
šŸš€

Board Bring-Up

  • 1
    Connect Arduino to PC via USB cable

    Power LED on board should light up.

  • 2
    Open Arduino IDE
  • 3
    Select Board

    Tools → Board → Arduino AVR Boards → Arduino Uno.

  • 4
    Select Port

    Tools → Port → COM3 (Windows) / /dev/ttyACM0 (Linux) / /dev/tty.usbmodem (Mac).

  • 5
    Open Blink Example

    File → Examples → 01.Basics → Blink.

  • 6
    Click Upload (→)

    Built-in LED on Pin 13 blinks — board is working!

šŸ”§ Troubleshooting

  • Port not detected? Use a data USB cable (not charge-only).
  • Windows: Install CH340 or CP2102 USB-Serial driver.
  • Restart Arduino IDE after plugging in the board.

Basic Components › LED
šŸ’”

LED – Light Emitting Diode

An LED emits light when current flows through it. Long leg = Anode (+), Short leg = Cathode (āˆ’). Always use a 220Ī© resistor in series.

āš ļø

Safety: Never connect an LED directly to 5V without a resistor — it will burn out immediately.

šŸ›’ Materials

šŸ”ŒArduino Uno
šŸ’”LED (Red)
🟰220Ω Resistor
🟫Breadboard
šŸ”—Jumper Wires

šŸ”Œ Wiring

Component Arduino Pin
LED Anode (long +) → 220Ī© Pin 8
LED Cathode (short āˆ’) GND

šŸ“ Sketch

Arduino C++ — LED Blink
const int led_pin = 8;

void setup() {
  pinMode(led_pin, OUTPUT);
}

void loop() {
  digitalWrite(led_pin, HIGH);  // LED ON
  delay(1000);
  digitalWrite(led_pin, LOW);   // LED OFF
  delay(1000);
}

šŸ” Explanation

  • pinMode(8, OUTPUT) configures pin 8 to supply voltage.
  • HIGH → 5V → LED ON. LOW → 0V → LED OFF.
  • delay(1000) pauses for 1000ms = 1 second.

šŸ”§ Troubleshooting

  • Not lighting? Check anode (long leg) is on resistor side.
  • Burned out? It was likely connected without a resistor.

Basic Components › Push Button
šŸ”˜

Push Button – Digital Input

A push button is a momentary switch. Using INPUT_PULLUP, the pin reads HIGH normally and LOW when pressed — no external resistor needed.

šŸ”Œ Wiring

Component Arduino Pin
Button Leg 1 Pin 13
Button Leg 2 GND
LED Anode (via 220Ī©) 5V
LED Cathode Pin 9

šŸ“ Sketch

Arduino C++ — Button Controls LED
const int BUTTON = 13;
const int LED    = 9;

void setup() {
  pinMode(BUTTON, INPUT_PULLUP);
  pinMode(LED, OUTPUT);
}

void loop() {
  if (digitalRead(BUTTON) == LOW) {
    digitalWrite(LED, LOW);   // Button pressed → LED ON
  } else {
    digitalWrite(LED, HIGH);  // Released → LED OFF
  }
}

šŸ” Explanation

  • INPUT_PULLUP enables internal ~20kĪ© pull-up. Pin reads HIGH normally.
  • Pressing button connects pin to GND → reads LOW.

Basic Components › Buzzer
šŸ””

Buzzer – Sound Output

Active Buzzer: Has built-in oscillator — produces fixed tone with HIGH/LOW. Passive Buzzer: Needs tone() function — can produce melodies.

šŸ”Œ Wiring

Buzzer Pin Arduino
VCC 5V
GND GND
I/O Signal Pin 2

šŸ“ Sketch

Arduino C++ — Active Buzzer Beep
const int buzzerPin = 2;

void setup() {
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  digitalWrite(buzzerPin, HIGH);  // Buzzer ON
  delay(1000);
  digitalWrite(buzzerPin, LOW);   // Buzzer OFF
  delay(1000);
}
šŸŽµ

Passive Buzzer: Use tone(2, 440, 500); to play note A4 for 500ms.


Basic Components › Trimpot
šŸŽ›ļø

Trimpot – Analog Input

A trimpot (variable resistor) outputs 0–5V at its middle (wiper) pin as you rotate it. Arduino reads this as 0–1023 via analogRead().

šŸ”Œ Wiring

Trimpot Pin Arduino
Left Pin 5V
Right Pin GND
Middle (Wiper) A0

šŸ“ Sketch

Arduino C++ — Trimpot Serial Monitor
int potPin = A0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int val = analogRead(potPin);   // 0–1023
  Serial.print("Pot Value: ");
  Serial.println(val);
  delay(500);
}

šŸ” Explanation

  • 0 = GND side (0V), 1023 = VCC side (5V), 512 ā‰ˆ midpoint.
  • Use map(val, 0, 1023, 0, 180) to convert to servo angle.

Basic Components › RGB LED
🌈

RGB LED – Colour Mixing

An RGB LED combines Red, Green, Blue in one package. Use PWM (0–255) to mix millions of colours. Common Cathode: long leg → GND.

šŸ”Œ Wiring (Common Cathode)

Pin Arduino (via 220Ī©)
Common Cathode (longest) GND
Red Pin 13
Green Pin 12
Blue Pin 11

šŸ“ Sketch — 7-Colour Cycle

Arduino C++ — RGB LED Colour Cycle
void setup() {
  pinMode(11, OUTPUT); // Blue
  pinMode(12, OUTPUT); // Green
  pinMode(13, OUTPUT); // Red
}

void loop() {
  analogWrite(13,255); analogWrite(12,0);   analogWrite(11,0);   delay(1000); // Red
  analogWrite(13,0);   analogWrite(12,255); analogWrite(11,0);   delay(1000); // Green
  analogWrite(13,0);   analogWrite(12,0);   analogWrite(11,255); delay(1000); // Blue
  analogWrite(13,255); analogWrite(12,255); analogWrite(11,0);   delay(1000); // Yellow
  analogWrite(13,0);   analogWrite(12,255); analogWrite(11,255); delay(1000); // Cyan
  analogWrite(13,255); analogWrite(12,0);   analogWrite(11,255); delay(1000); // Magenta
  analogWrite(13,255); analogWrite(12,255); analogWrite(11,255); delay(1000); // White
}

Displays › 7-Segment Display
šŸ”¢

7-Segment Display

7 LED segments (a–g) form digits 0–9. Common Anode: all anodes share +5V, segments turn ON with LOW signal.

0
1
2
3
4
5
6
7
8
9

šŸ”Œ Wiring (Common Anode, each via 220Ī©)

Segment Arduino Pin
CA (Common Anode) 5V
a, b, c, d, e, f, g, dp 2, 3, 4, 5, 6, 7, 8, 9

šŸ“ Sketch — Count 0 to 9

Arduino C++ — 7-Segment Counter
const int segPins[8] = {2,3,4,5,6,7,8,9};

// Common Anode: 0=segment ON, 1=segment OFF
const byte digitPatterns[10] = {
  B01000000,  // 0
  B01111001,  // 1
  B00100100,  // 2
  B00110000,  // 3
  B00011001,  // 4
  B00010010,  // 5
  B00000010,  // 6
  B01111000,  // 7
  B00000000,  // 8
  B00010000   // 9
};

void setup() {
  for(int i=0;i<8;i++) pinMode(segPins[i], OUTPUT);
}

void loop() {
  for(int d=0;d<10;d++){
    for(int i=0;i<8;i++) digitalWrite(segPins[i], bitRead(digitPatterns[d],i));
    delay(1000);
  }
}

šŸ”§ Troubleshooting

  • Wrong segments? Confirm Common Anode type.
  • All ON? Ensure CA pin is connected to 5V.

Displays › I2C LCD 16Ɨ2
šŸ“Ÿ

I2C LCD 16Ɨ2 Display

Displays 32 characters over just 4 wires using the I2C protocol. Most modules use address 0x27 or 0x3F.

šŸ“¦

Library: Install LiquidCrystal I2C by Frank de Brabander via Sketch → Include Library → Manage Libraries.

šŸ”Œ Wiring — Only 4 Wires!

LCD Pin Arduino
GND GND
VCC 5V
SDA A4
SCL A5

šŸ“ Step 1: I2C Scanner

Arduino C++ — I2C Scanner
#include <Wire.h>
void setup() {
  Wire.begin(); Serial.begin(9600);
  for(byte a=1;a<127;a++){
    Wire.beginTransmission(a);
    if(Wire.endTransmission()==0){
      Serial.print("Found I2C at 0x"); Serial.println(a,HEX);
    }
  }
}
void loop(){}

šŸ“ Step 2: Hello World

Arduino C++ — LCD Hello World
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // Change 0x27 if needed

void setup() {
  lcd.begin(16, 2);
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Hello Makers!!");
  lcd.setCursor(0, 1);
  lcd.print("AnuElectronics");
}

void loop() {
  lcd.clear();
  lcd.setCursor(0,0); lcd.print("Temp: 28.5 C");
  lcd.setCursor(0,1); lcd.print("Hum:  65.0 %");
  delay(2000);
}

šŸ”§ Troubleshooting

  • Blank screen? Adjust contrast pot on back of I2C module.
  • Wrong address? Run I2C scanner to find correct address (0x27 or 0x3F).

Sensors › LDR Light Sensor
ā˜€ļø

LDR Light Sensor

LDR (Light Dependent Resistor) changes resistance with light. More light = lower resistance = higher voltage on A0. The module DO pin outputs LOW when dark.

šŸ”Œ Wiring

LDR Module Pin Arduino
VCC / GND 5V / GND
AO (Analog) A0
DO (Digital) Pin 2

šŸ“ Sketch — Auto LED

Arduino C++ — LDR Auto LED
const int ldrPin = 2, ledPin = 13;

void setup() {
  pinMode(ldrPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int val = analogRead(A0);
  if(digitalRead(ldrPin) == LOW) {
    digitalWrite(ledPin, HIGH);
    Serial.println("DARK — LED ON");
  } else {
    digitalWrite(ledPin, LOW);
    Serial.println("BRIGHT — LED OFF");
  }
  delay(500);
}

Sensors › Flame Sensor
šŸ”„

Flame Sensor

Detects IR radiation from flames. Outputs LOW when fire is detected. Range: 20–100 cm.

šŸ”Œ Wiring

Module Pin Arduino
VCC / GND / DO 5V / GND / Pin 2

šŸ“ Sketch

Arduino C++ — Flame Fire Alert
const int flamePin=2, buzzerPin=3, ledPin=13;

void setup() {
  pinMode(flamePin,INPUT); pinMode(buzzerPin,OUTPUT); pinMode(ledPin,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if(digitalRead(flamePin) == LOW) {
    digitalWrite(ledPin,HIGH); tone(buzzerPin,1000);
    Serial.println("FIRE DETECTED!");
  } else {
    digitalWrite(ledPin,LOW); noTone(buzzerPin);
    Serial.println("Safe.");
  }
  delay(200);
}
āš ļø

Handle open flames with extreme care. Test briefly only. Keep away from flammable materials.


Sensors › Vibration Sensor
šŸ“³

Vibration Sensor SW-420

Detects physical vibrations. Outputs HIGH when vibration is detected. Ideal for tamper/security alarms.

šŸ”Œ Wiring

Module Pin Arduino
VCC / GND / DO 5V / GND / Pin 2

šŸ“ Sketch

Arduino C++ — Vibration Alert
const int vibPin=2, buzzerPin=3, ledPin=13;

void setup() {
  pinMode(vibPin,INPUT); pinMode(buzzerPin,OUTPUT); pinMode(ledPin,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if(digitalRead(vibPin) == HIGH) {
    digitalWrite(ledPin,HIGH); tone(buzzerPin,1500);
    Serial.println("Vibration Detected!");
    delay(500);
  } else {
    digitalWrite(ledPin,LOW); noTone(buzzerPin);
  }
  delay(100);
}

Sensors › Joystick Module
šŸ•¹ļø

Joystick Module

Two potentiometers (X and Y) + push button. X and Y return 0–1023 each. Centre ā‰ˆ 512.

šŸ”Œ Wiring

Joystick Pin Arduino
GND / VCC GND / 5V
VRx / VRy / SW A0 / A1 / Pin 2

šŸ“ Sketch — Direction LEDs

Arduino C++ — Joystick Direction LEDs
const int VRx=A0,VRy=A1,SW=2;
const int L=3,R=4,U=5,D=6;

void setup(){
  pinMode(SW,INPUT_PULLUP);
  for(int p=3;p<=6;p++) pinMode(p,OUTPUT);
  Serial.begin(9600);
}

void loop(){
  int x=analogRead(VRx), y=analogRead(VRy);
  digitalWrite(L, x<300); digitalWrite(R, x>700);
  digitalWrite(U, y<300); digitalWrite(D, y>700);
  Serial.print("X:"); Serial.print(x);
  Serial.print(" Y:"); Serial.println(y);
  delay(100);
}

Sensors › IR Obstacle Sensor
šŸ“”

IR Obstacle Sensor

Detects objects within 2–30 cm using infrared reflection. Output is LOW when obstacle detected. Adjust range with onboard potentiometer.

šŸ”Œ Wiring

IR Module Pin Arduino
VCC / GND / OUT 5V / GND / Pin 2

šŸ“ Sketch

Arduino C++ — IR Obstacle Detector
const int irPin=2, ledPin=13;

void setup(){
  pinMode(irPin,INPUT); pinMode(ledPin,OUTPUT);
  Serial.begin(9600);
}

void loop(){
  if(digitalRead(irPin)==LOW){
    digitalWrite(ledPin,HIGH);
    Serial.println("Obstacle Detected!");
  } else {
    digitalWrite(ledPin,LOW);
    Serial.println("Path Clear");
  }
  delay(200);
}

Sensors › Ultrasonic HC-SR04
šŸ“

Ultrasonic HC-SR04 Sensor

Measures distance 2–500 cm using sound waves. Sends pulse on Trig, measures echo duration on Echo. Formula: Distance (cm) = duration Ɨ 0.0343 / 2

šŸ”Œ Wiring

HC-SR04 Pin Arduino
VCC / GND 5V / GND
Trig / Echo Pin 9 / Pin 8

šŸ“ Sketch

Arduino C++ — Ultrasonic Distance
const int trigPin=9, echoPin=8;

void setup(){
  Serial.begin(9600);
  pinMode(trigPin,OUTPUT); pinMode(echoPin,INPUT);
}

void loop(){
  digitalWrite(trigPin,LOW); delayMicroseconds(2);
  digitalWrite(trigPin,HIGH); delayMicroseconds(10);
  digitalWrite(trigPin,LOW);
  long dur = pulseIn(echoPin,HIGH);
  long dist = dur * 0.0343 / 2;
  Serial.print("Distance: "); Serial.print(dist); Serial.println(" cm");
  delay(500);
}

šŸ” Explanation

  • 10µs HIGH pulse on Trig sends ultrasonic burst.
  • pulseIn(echoPin, HIGH) measures time for echo to return.
  • Divide by 2 because sound travels TO object AND back.

Sensors › DHT11 Temperature & Humidity
šŸŒ”ļø

DHT11 Temp & Humidity

Measures temperature (0–50°C ±2°C) and humidity (20–90% RH ±5%) via a single data pin. Minimum sample interval: 2 seconds.

šŸ“¦

Library: Install DHT sensor library by Adafruit + Adafruit Unified Sensor from Library Manager.

šŸ”Œ Wiring

DHT11 Pin Arduino
VCC / GND / DATA 5V / GND / Pin 2

šŸ“ Sketch

Arduino C++ — DHT11 Temperature & Humidity
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup(){
  Serial.begin(9600);
  dht.begin();
}

void loop(){
  delay(2000);
  float hum  = dht.readHumidity();
  float temp = dht.readTemperature();
  if(isnan(hum) || isnan(temp)){
    Serial.println("ERROR: Sensor read failed!");
    return;
  }
  Serial.print("Humidity: ");    Serial.print(hum);  Serial.println(" %");
  Serial.print("Temperature: "); Serial.print(temp); Serial.println(" C");
  Serial.println("---");
}

šŸ”§ Troubleshooting

  • "Failed to read"? Add 10kĪ© pull-up between DATA and VCC.
  • Install both DHT sensor library AND Adafruit Unified Sensor.
  • Allow 30-second warm-up after power-on for accurate readings.

Actuators › Relay Module
⚔

Relay Module

An electrically operated switch. Lets 5V Arduino logic control high-voltage AC/DC devices. Terminals: COM, NO (Normally Open), NC (Normally Closed).

āš ļø

When connecting to AC mains, ensure proper insulation. Work under expert supervision.

šŸ”Œ Wiring

Relay Module Pin Arduino / Circuit
VCC / GND / IN 5V / GND / Pin 2
COM → NO → LED → GND Load side (test with LED + 220Ī©)

šŸ“ Sketch

Arduino C++ — Relay Control
const int relayPin = 2;

void setup(){
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW);
  Serial.begin(9600);
}

void loop(){
  digitalWrite(relayPin, HIGH);
  Serial.println("Relay ON — Load Active");
  delay(2000);
  digitalWrite(relayPin, LOW);
  Serial.println("Relay OFF");
  delay(2000);
}

šŸ” Note

  • Some relay modules are active LOW — use LOW to activate, HIGH to deactivate.

Actuators › Servo Motor
āš™ļø

Servo Motor

Rotates precisely 0°–180°. Three wires: Brown/Black = GND, Red = 5V, Orange/Yellow = Signal. Uses built-in Servo library.

šŸ”Œ Wiring

Wire Arduino
Brown / Black (GND) GND
Red (VCC) 5V
Orange / Yellow (Signal) Pin 3 (~PWM)

šŸ“ Sketch — Sweep 0° to 180°

Arduino C++ — Servo Sweep
#include <Servo.h>
Servo myServo;
int pos = 0;

void setup(){
  myServo.attach(3);
  Serial.begin(9600);
}

void loop(){
  for(pos=0; pos<=180; pos++){
    myServo.write(pos);
    Serial.println("Angle: " + String(pos) + "deg");
    delay(15);
  }
  delay(500);
  for(pos=180; pos>=0; pos--){
    myServo.write(pos);
    delay(15);
  }
  delay(500);
}

šŸ“ Bonus — Pot Controlled Servo

Arduino C++ — Potentiometer → Servo Angle
#include <Servo.h>
Servo myServo;
const int potPin = A0;

void setup(){ myServo.attach(3); }

void loop(){
  int angle = map(analogRead(potPin), 0, 1023, 0, 180);
  myServo.write(angle);
  delay(15);
}

Actuators › Stepper Motor 28BYJ-48
šŸ”©

Stepper Motor + ULN2003

28BYJ-48 is a 5V stepper motor with 2048 steps/revolution. Needs ULN2003 driver board to interface with Arduino.

šŸ”Œ Wiring (ULN2003 → Arduino)

ULN2003 Pin Arduino
IN1 / IN2 / IN3 / IN4 Pin 8 / 9 / 10 / 11
VCC / GND 5V / GND
Stepper connector Plug motor cable into ULN2003 socket

šŸ“ Sketch — CW and CCW Revolution

Arduino C++ — Stepper Motor Control
#include <Stepper.h>
const int stepsPerRevolution = 2048;
// Note pin order: IN1,IN3,IN2,IN4 for correct rotation
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

void setup(){
  myStepper.setSpeed(15); // 15 RPM
  Serial.begin(9600);
}

void loop(){
  Serial.println("Clockwise — 1 revolution");
  myStepper.step(stepsPerRevolution);
  delay(1000);
  Serial.println("Counter-Clockwise — 1 revolution");
  myStepper.step(-stepsPerRevolution);
  delay(1000);
}

šŸ”§ Troubleshooting

  • Vibrates but won't rotate? Swap IN2 and IN3 connections.
  • Getting hot? Don't leave powered while stationary.
  • Skipping steps? Use external 5V supply or reduce speed.

Projects › Automatic Street Light
🌃

Auto Street Light Controller

Automatically turns ON a street light in darkness and OFF in daylight using an LDR sensor — exactly like real street lights.

šŸ”Œ Wiring

Component Arduino
LDR Module: VCC/GND/DO 5V/GND/Pin 2
LED (via 220Ī©) Pin 13

šŸ“ Full Project Sketch

Arduino C++ — Auto Street Light
const int ldrPin=2, ledPin=13;

void setup(){
  pinMode(ldrPin,INPUT); pinMode(ledPin,OUTPUT);
  Serial.begin(9600);
  Serial.println("=== Auto Street Light Controller ===");
}

void loop(){
  if(digitalRead(ldrPin) == LOW){
    digitalWrite(ledPin,HIGH);
    Serial.println("Night — Light ON");
  } else {
    digitalWrite(ledPin,LOW);
    Serial.println("Day — Light OFF");
  }
  delay(500);
}
  • 1
    Upload & open Serial Monitor
  • 2
    Cover LDR with hand

    LED turns ON — simulating night.

  • 3
    Expose to light

    LED turns OFF. Adjust sensitivity pot on LDR module.

  • 4
    Scale up

    Replace LED with a relay module to control an actual lamp.


Projects › Smart Home Security System
🚨

Smart Home Security System

Detects vibration (tamper/intrusion) and triggers a rapid LED + buzzer alarm.

šŸ”Œ Wiring

Component Arduino
Vibration Sensor DO Pin 2
Buzzer Signal Pin 3
Red LED (via 220Ī©) Pin 13

šŸ“ Full Project Sketch

Arduino C++ — Smart Security System
const int vibPin=2, buzzerPin=3, ledPin=13;
bool alarmActive=false;

void setup(){
  pinMode(vibPin,INPUT); pinMode(buzzerPin,OUTPUT); pinMode(ledPin,OUTPUT);
  Serial.begin(9600);
  Serial.println("=== Security System Armed ===");
}

void loop(){
  if(digitalRead(vibPin)==HIGH && !alarmActive){
    alarmActive=true;
    Serial.println("INTRUSION DETECTED!");
  }
  if(alarmActive){
    for(int i=0;i<5;i++){
      digitalWrite(ledPin,HIGH); tone(buzzerPin,1800); delay(150);
      digitalWrite(ledPin,LOW);  noTone(buzzerPin);    delay(100);
    }
    alarmActive=false;
    Serial.println("Alarm complete. Re-armed.");
  }
  delay(100);
}

Projects › Weather Station
šŸŒ¦ļø

Weather Station – DHT11 + I2C LCD

Displays live temperature and humidity on a 16Ɨ2 I2C LCD — a complete portable weather station!

šŸ”Œ Wiring

Component Arduino
DHT11: VCC/GND/DATA 5V/GND/Pin 2
LCD I2C: VCC/GND/SDA/SCL 5V/GND/A4/A5

šŸ“ Full Project Sketch

Arduino C++ — Weather Station
#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup(){
  lcd.begin(16,2); lcd.backlight(); dht.begin();
  lcd.setCursor(0,0); lcd.print("Weather Station");
  lcd.setCursor(0,1); lcd.print("Initializing...");
  delay(2000); lcd.clear();
}

void loop(){
  float hum=dht.readHumidity(), temp=dht.readTemperature();
  if(isnan(hum)||isnan(temp)){ lcd.print("Sensor Error!"); return; }
  lcd.setCursor(0,0);
  lcd.print("Temp: "); lcd.print(temp,1); lcd.print((char)223); lcd.print("C    ");
  lcd.setCursor(0,1);
  lcd.print("Hum:  "); lcd.print(hum,1); lcd.print("%      ");
  delay(2000);
}

Projects › Car Parking Sensor
šŸ…æļø

Car Parking Sensor

Beeps faster as obstacle gets closer — exactly like reverse parking sensors! Green = Safe, Yellow = Caution, Red = Danger.

šŸ”Œ Wiring

Component Arduino Pins
HC-SR04 Trig/Echo Pin 9/Pin 8
Buzzer Pin 3
Green/Yellow/Red LED 4/5/6

šŸ“ Full Project Sketch

Arduino C++ — Car Parking Sensor
const int trigPin=9, echoPin=8, buzzerPin=3;
const int gLED=4, yLED=5, rLED=6;

void setup(){
  pinMode(trigPin,OUTPUT); pinMode(echoPin,INPUT);
  pinMode(buzzerPin,OUTPUT);
  for(int p=4;p<=6;p++) pinMode(p,OUTPUT);
  Serial.begin(9600);
}

long getDistance(){
  digitalWrite(trigPin,LOW); delayMicroseconds(2);
  digitalWrite(trigPin,HIGH); delayMicroseconds(10);
  digitalWrite(trigPin,LOW);
  return pulseIn(echoPin,HIGH)*0.0343/2;
}

void loop(){
  long d=getDistance();
  Serial.print("Distance: "); Serial.print(d); Serial.println(" cm");
  digitalWrite(gLED,LOW); digitalWrite(yLED,LOW); digitalWrite(rLED,LOW); noTone(buzzerPin);
  if(d>30){
    digitalWrite(gLED,HIGH); Serial.println("SAFE"); delay(500);
  } else if(d>15){
    digitalWrite(yLED,HIGH); tone(buzzerPin,800); Serial.println("CAUTION");
    delay(300); noTone(buzzerPin); delay(300);
  } else {
    digitalWrite(rLED,HIGH); tone(buzzerPin,1500); Serial.println("DANGER — STOP!");
    delay(100); noTone(buzzerPin); delay(100);
  }
}

Projects › Touchless Doorbell
🚪

Touchless Doorbell System

IR sensor detects visitor at door and plays a musical doorbell tone — completely touchless!

šŸ”Œ Wiring

Component Arduino
IR Sensor OUT Pin 2
Passive Buzzer Pin 3
LED (via 220Ī©) Pin 13

šŸ“ Full Project Sketch

Arduino C++ — Touchless Doorbell
const int irPin=2, buzzerPin=3, ledPin=13;
bool ringPlayed=false;

#define NOTE_C5 523
#define NOTE_E5 659

void playDoorbell(){
  tone(buzzerPin,NOTE_E5,300); delay(350);
  tone(buzzerPin,NOTE_C5,500); delay(550);
  noTone(buzzerPin);
}

void setup(){
  pinMode(irPin,INPUT); pinMode(buzzerPin,OUTPUT); pinMode(ledPin,OUTPUT);
  Serial.begin(9600);
  Serial.println("=== Touchless Doorbell Ready ===");
}

void loop(){
  if(digitalRead(irPin)==LOW && !ringPlayed){
    Serial.println("Visitor! Ringing...");
    digitalWrite(ledPin,HIGH);
    playDoorbell();
    digitalWrite(ledPin,LOW);
    ringPlayed=true;
    delay(3000);  // 3-second cooldown
    ringPlayed=false;
  }
  delay(50);
}
šŸ’”

Use a passive buzzer for this project — active buzzers cannot produce musical notes via tone().


Reference › Resistor Colour Code
šŸŽØ

Resistor Colour Code Chart

Resistors use coloured bands to indicate resistance. Read left to right starting from the band closest to an end.

4-Band: Value = (Band1 Ɨ 10 + Band2) Ɨ 10^Multiplier ± Tolerance
5-Band: Value = (Band1 Ɨ 100 + Band2 Ɨ 10 + Band3) Ɨ 10^Multiplier ± Tolerance
Colour Digit Multiplier Tolerance
Black 0 Ɨ1 Ī© —
Brown 1 Ɨ10 Ī© ±1%
Red 2 Ɨ100 Ī© ±2%
Orange 3 Ɨ1 kĪ© —
Yellow 4 Ɨ10 kĪ© —
Green 5 Ɨ100 kĪ© ±0.5%
Blue 6 Ɨ1 MĪ© ±0.25%
Violet 7 Ɨ10 MĪ© ±0.1%
Grey 8 Ɨ100 MĪ© ±0.05%
White 9 Ɨ1 GĪ© —
Gold — Ɨ0.1 ±5%
Silver — Ɨ0.01 ±10%

šŸ“– Quick Reference — Common Resistors

Colours Value
Red – Red – Brown – Gold 220 Ī© ±5% (LED current limiter)
Brown – Black – Red – Gold 1 kĪ© ±5%
Brown – Black – Orange – Gold 10 kĪ© ±5% (pull-up/pull-down)
Orange – Orange – Orange – Gold 33 kĪ© ±5%
šŸ’”

Memory Trick: "B B ROY Goes Brave Victory Giving Willpower" → Black, Brown, Red, Orange, Yellow, Green, Blue, Violet, Grey, White.