Arduino Smart Starter Kit
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.
Published by AnuElectronics.com Ā· Arduino Starter Kit Series
Table of Contents
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?
Low-cost boards accessible to students and hobbyists worldwide.
Works on Windows, macOS, and Linux.
Beginner-friendly environment with rich library support.
Both hardware and software are fully open source.
Millions of users, tutorials, and libraries available online.
Go from idea to working prototype in minutes.
š ļø Common Applications
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
Serial communication ā receive and transmit TTL data.
External interrupts ā trigger on LOW, rising/falling edge.
PWM output ā 8-bit (0ā255).
SPI: SS, MOSI, MISO, SCK.
Onboard LED connected to digital pin 13.
10-bit ADC: reads 0ā1023.
I2C / TWI communication.
Pull LOW to reset the microcontroller.
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
-
1Download
Visit arduino.cc, select your OS (Windows/macOS/Linux), download installer.
-
2Windows
Run .exe installer, follow wizard, accept license, install all components, click Finish.
-
3macOS
Open .dmg file, drag Arduino to Applications folder, launch from Applications.
-
4Linux
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.
Arduino Programming Basics
Arduino programs are called sketches written in C/C++. Every sketch must have two core functions:
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); |
Board Bring-Up
-
1Connect Arduino to PC via USB cable
Power LED on board should light up.
-
2Open Arduino IDE
-
3Select Board
Tools ā Board ā Arduino AVR Boards ā Arduino Uno.
-
4Select Port
Tools ā Port ā COM3 (Windows) / /dev/ttyACM0 (Linux) / /dev/tty.usbmodem (Mac).
-
5Open Blink Example
File ā Examples ā 01.Basics ā Blink.
-
6Click 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.
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
š Wiring
| Component | Arduino Pin |
|---|---|
| LED Anode (long +) ā 220Ī© | Pin 8 |
| LED Cathode (short ā) | GND |
š Sketch
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.
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
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_PULLUPenables internal ~20kĪ© pull-up. Pin reads HIGH normally. - Pressing button connects pin to GND ā reads LOW.
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
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.
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
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.
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
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
}
7-Segment Display
7 LED segments (aāg) form digits 0ā9. Common Anode: all anodes share +5V, segments turn ON with LOW signal.
š 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
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.
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
#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
#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).
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
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);
}
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
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.
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
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);
}
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
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);
}
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
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);
}
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
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.
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
#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.
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
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.
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°
#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
#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);
}
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
#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.
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
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);
}
-
1Upload & open Serial Monitor
-
2Cover LDR with hand
LED turns ON ā simulating night.
-
3Expose to light
LED turns OFF. Adjust sensitivity pot on LDR module.
-
4Scale up
Replace LED with a relay module to control an actual lamp.
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
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);
}
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
#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);
}
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
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);
}
}
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
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().
Resistor Colour Code Chart
Resistors use coloured bands to indicate resistance. Read left to right starting from the band closest to an end.
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.