0% found this document useful (0 votes)
12 views22 pages

Arduino Case Studies for Smart Systems

Uploaded by

Muthu karuppan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views22 pages

Arduino Case Studies for Smart Systems

Uploaded by

Muthu karuppan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CASE STUDY 1 – Smart Irrigation System

1) Components Required
Component Qty

Arduino UNO 1

Soil Moisture Sensor 1

Relay Module 1

Water Pump 1

Jumper Wires Few

2) Circuit Connections
Arduino Pin Connected To

A0 Soil Moisture Sensor OUT

D8 Relay IN

5V / GND Common Power & Ground

3) Arduino Code (with Serial Output)


/*
* Smart Irrigation System
* Water pump turns ON when soil is dry
*/

#define SOIL_PIN A0
#define RELAY_PIN 8

int soilValue = 0;

void setup() {
pinMode(RELAY_PIN, OUTPUT);
[Link](9600);
[Link]("=== Smart Irrigation System Started ===");
}

void loop() {
soilValue = analogRead(SOIL_PIN);

[Link]("Soil Moisture : " + String(soilValue));

if (soilValue < 500) {


[Link]("Status : Soil Dry -> Pump ON");
digitalWrite(RELAY_PIN, HIGH);
} else {
[Link]("Status : Soil Wet -> Pump OFF");
digitalWrite(RELAY_PIN, LOW);
}

[Link]("------------------");
delay(1000);
}

4) Expected Serial Output


=== Smart Irrigation System Started ===
Soil Moisture : 430
Status : Soil Dry -> Pump ON
------------------
Soil Moisture : 690
Status : Soil Wet -> Pump OFF
------------------
(repeats...)
CASE STUDY 2 – Smart Parking System
1) Components Required
Component Qty

Arduino UNO 1

Ultrasonic 1
Sensor

Red LED 1

Green LED 1

Jumper Wires Few

2) Circuit Connections
Arduino Pin Connected To

D9 Ultrasonic TRIG

D10 Ultrasonic ECHO

D6 Red LED

D7 Green LED

5V / GND Common Power

3) Arduino Code (with Serial Output)


/*
* Smart Parking System
* Shows parking slot Occupied/Free
*/

#define TRIG_PIN 9
#define ECHO_PIN 10
#define RED_LED 6
#define GREEN_LED 7
long duration;
int distance;

void setup() {
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
[Link](9600);
[Link]("=== Smart Parking System Started ===");
}

void loop() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

duration = pulseIn(ECHO_PIN, HIGH);


distance = duration * 0.034 / 2;

[Link]("Distance : " + String(distance) + " cm");

if (distance < 10) {


[Link]("Status : Slot Occupied");
digitalWrite(RED_LED, HIGH);
digitalWrite(GREEN_LED, LOW);
} else {
[Link]("Status : Slot Free");
digitalWrite(RED_LED, LOW);
digitalWrite(GREEN_LED, HIGH);
}

[Link]("------------------");
delay(700);
}
4) Expected Serial Output
=== Smart Parking System Started ===
Distance : 7 cm
Status : Slot Occupied
------------------
Distance : 32 cm
Status : Slot Free
------------------
(repeats…)

CASE STUDY 3 – Exam Hall Monitoring System


(Malpractice Alert)
1) Components Required
Component Qty

Arduino UNO 1

PIR Sensor 1

Buzzer 1

Jumper Wires Few

2) Circuit Connections
Arduino Pin Connected
To

D7 PIR OUT

D8 Buzzer +

GND Buzzer –

5V / GND Power

3) Arduino Code (with Serial Output)


/*
* Exam Hall Monitoring System
* Detects movement & alerts via buzzer
*/

#define PIR_PIN 7
#define BUZZER_PIN 8

void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
[Link](9600);
[Link]("=== Exam Monitoring System Started ===");
}

void loop() {
int motion = digitalRead(PIR_PIN);

if (motion == HIGH) {
[Link]("Movement Detected!");
[Link]("Action : Malpractice Alert -> Buzzer ON");
digitalWrite(BUZZER_PIN, HIGH);
} else {
[Link]("No Movement");
[Link]("Action : Normal -> Buzzer OFF");
digitalWrite(BUZZER_PIN, LOW);
}

[Link]("------------------");
delay(800);
}

4) Expected Serial Output


=== Exam Monitoring System Started ===
No Movement
Action : Normal -> Buzzer OFF
------------------
Movement Detected!
Action : Malpractice Alert -> Buzzer ON
------------------
(repeats…)

CASE STUDY 4 – Home Automation System (LDR +


Temperature Based Control)
1) Components Required
Component Qty

Arduino UNO 1

LDR (Light Sensor) 1

10kΩ Resistor (for LDR) 1

DHT11 Temperature Sensor 1

LED (for Light) 1

DC Fan / Motor (or LED to represent fan) 1

Jumper Wires Few

2) Circuit Connections
Arduino Pin Connected To

A0 LDR Output

D7 DHT11 Data Pin

D9 Light (LED)

D10 Fan (Output device)

5V / GND Common Power


3) Arduino Code (Serial Output Included)
/*
* Home Automation System
* Light controlled by LDR, Fan controlled by Temperature
*/

#include <DHT.h>
#define DHTPIN 7
#define DHTTYPE DHT11
#define LDR_PIN A0
#define LIGHT_PIN 9
#define FAN_PIN 10

DHT dht(DHTPIN, DHTTYPE);

void setup() {
[Link](9600);
[Link]();
pinMode(LIGHT_PIN, OUTPUT);
pinMode(FAN_PIN, OUTPUT);
[Link]("=== Home Automation System Started ===");
}

void loop() {
int lightValue = analogRead(LDR_PIN);
float temperature = [Link]();

[Link]("Light Value : " + String(lightValue));


[Link]("Temperature : " + String(temperature));

if (lightValue < 500) {


[Link]("Action : Light ON");
digitalWrite(LIGHT_PIN, HIGH);
} else {
[Link]("Action : Light OFF");
digitalWrite(LIGHT_PIN, LOW);
}
if (temperature > 28) {
[Link]("Action : Fan ON");
digitalWrite(FAN_PIN, HIGH);
} else {
[Link]("Action : Fan OFF");
digitalWrite(FAN_PIN, LOW);
}

[Link]("----------------------");
delay(1500);
}

4) Expected Serial Monitor Output


=== Home Automation System Started ===
Light Value : 312
Temperature : 29.4
Action : Light ON
Action : Fan ON
----------------------
Light Value : 790
Temperature : 26.1
Action : Light OFF
Action : Fan OFF
----------------------
(repeats…)

CASE STUDY 5 – Vending Machine (Keypad + Servo)


1) Components Required
Component Qty

Arduino UNO 1

4x3 Keypad 1
Servo Motor 1

LCD 16x2 (Optional) 1

Jumper Wires Few

2) Circuit Connections
Arduino Pin Connected
To

D2–D8 Keypad Pins

D9 Servo Signal

5V / GND Power

3) Arduino Code (Serial Output Included)


/*
* Vending Machine System
* Food dispensed based on entered code
*/

#include <Keypad.h>
#include <Servo.h>

Servo myservo;

const byte ROWS = 4, COLS = 3;


char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};

byte rowPins[ROWS] = {2,3,4,5};


byte colPins[COLS] = {6,7,8};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS,
COLS);

void setup() {
[Link](9600);
[Link](9);
[Link]("=== Vending Machine Started ===");
[Link]("Enter Code : ");
}

void loop() {
char key = [Link]();
if (key) {
[Link]("Code Entered : " + String(key));

if (key == '1') {
[Link]("Food 1 Selected -> Dispensing...");
[Link](90);
delay(1000);
[Link](0);
} else {
[Link]("Invalid Code");
}
[Link]("---------------------");
}
}

4) Expected Serial Output


=== Vending Machine Started ===
Enter Code :
Code Entered : 1
Food 1 Selected -> Dispensing...
---------------------
Code Entered : 5
Invalid Code
---------------------
CASE STUDY 6 – Smart Streetlight System (LDR +
Motion)
1) Components Required
Component Qty

Arduino UNO 1

LDR Sensor 1

PIR Motion Sensor 1

LED (Streetlight) 1

Jumper Wires Few

2) Circuit Connections
Arduino Pin Connected To

A0 LDR Output

D7 PIR Output

D9 LED (Streetlight)

5V / GND Common Power

3) Arduino Code (Serial Output Included)


/*
* Smart Streetlight System
* Light ON at night; Bright only on motion
*/

#define LDR_PIN A0
#define PIR_PIN 7
#define LED_PIN 9

void setup() {
[Link](9600);
pinMode(PIR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
[Link]("=== Smart Streetlight System Started ===");
}

void loop() {
int lightValue = analogRead(LDR_PIN);
int motion = digitalRead(PIR_PIN);

[Link]("Light Value : " + String(lightValue));


[Link]("Motion : " + String(motion));

if (lightValue < 400) {


if (motion == HIGH) {
[Link]("Action : Bright Light");
analogWrite(LED_PIN, 255);
} else {
[Link]("Action : Dim Light");
analogWrite(LED_PIN, 80);
}
} else {
[Link]("Action : Light OFF (Day Time)");
analogWrite(LED_PIN, 0);
}

[Link]("-------------------");
delay(800);
}

4) Expected Serial Output


=== Smart Streetlight System Started ===
Light Value : 310
Motion : 1
Action : Bright Light
-------------------
Light Value : 320
Motion : 0
Action : Dim Light
-------------------
Light Value : 780
Motion : 0
Action : Light OFF (Day Time)
-------------------

CASE STUDY 7 – Traffic Control System (with Pedestrian


Button)
1) Components Required
Component Qty

Arduino UNO 1

Red LED 1

Yellow LED 1

Green LED 1

Push Button 1

10kΩ Resistor 1

2) Circuit Connections
Arduino Pin Connected
To

D9 Red LED

D10 Yellow LED

D11 Green LED


D7 Push Button

3) Arduino Code (with Serial Output)


/*
* Traffic Control System
* Cars stop when pedestrian presses button
*/

#define RED 9
#define YELLOW 10
#define GREEN 11
#define PED_BUTTON 7

void setup() {
pinMode(RED, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(PED_BUTTON, INPUT_PULLUP);
[Link](9600);
[Link]("=== Traffic Control System Started ===");
}

void loop() {
if (digitalRead(PED_BUTTON) == LOW) {
[Link]("Pedestrian Request Detected");
[Link]("Signal : YELLOW -> RED");
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
delay(2000);

digitalWrite(YELLOW, LOW);
digitalWrite(RED, HIGH);
[Link]("Signal : STOP for Cars");
delay(5000);

[Link]("Signal : GREEN for Cars");


digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
} else {
[Link]("Normal Operation : Cars GO");
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, LOW);
}

[Link]("---------------------");
delay(1000);
}

4) Expected Serial Output


=== Traffic Control System Started ===
Normal Operation : Cars GO
---------------------
Pedestrian Request Detected
Signal : YELLOW -> RED
Signal : STOP for Cars
---------------------
Signal : GREEN for Cars
---------------------

CASE STUDY 8 – Car Ambience Control System


(Temperature-based)
1) Components Required
Component Qty

Arduino UNO 1

DHT11 Sensor 1

DC Fan / LED 1
2) Circuit Connections
Arduino Pin Connected To

D7 DHT11 Output

D9 Fan / LED Output

3) Arduino Code (with Serial Output)


/*
* Car Ambience Control System
* Controls fan based on temperature
*/

#include <DHT.h>
#define DHTPIN 7
#define DHTTYPE DHT11
#define FAN_PIN 9

DHT dht(DHTPIN, DHTTYPE);

void setup() {
[Link](9600);
[Link]();
pinMode(FAN_PIN, OUTPUT);
[Link]("=== Car Ambience System Started ===");
}

void loop() {
float temp = [Link]();
[Link]("Temperature : " + String(temp));

if (temp > 30) {


[Link]("Action : Fan ON");
digitalWrite(FAN_PIN, HIGH);
} else {
[Link]("Action : Fan OFF");
digitalWrite(FAN_PIN, LOW);
}
[Link]("------------------");
delay(1500);
}

4) Expected Serial Output


=== Car Ambience System Started ===
Temperature : 31.3
Action : Fan ON
------------------
Temperature : 26.8
Action : Fan OFF
------------------

CASE STUDY 9 – Library Management System


(RFID-based)
1) Components Required
Component Qty

Arduino UNO 1

RFID RC522 1
Reader

RFID Tag/Card 1

2) Circuit Connections
Arduino Pin Connected
To

D10 RFID SDA

D9 RST
D11 MOSI

D12 MISO

D13 SCK

3) Arduino Code (with Serial Output)


/*
* Library Management System
* Displays RFID tag when scanned
*/

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9

MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
[Link]();
rfid.PCD_Init();
[Link](9600);
[Link]("=== Library System Started ===");
}

void loop() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial())
return;

[Link]("CARD ID : ");
for (byte i = 0; i < [Link]; i++) {
[Link]([Link][i], HEX);
}
[Link]("\nStatus : Book Updated");
[Link]("-------------------");
delay(1000);
}

4) Expected Serial Output


=== Library System Started ===
CARD ID : 3A5F9C2B
Status : Book Updated
-------------------

CASE STUDY 10 – Auditorium Maintenance System (Air


Quality + PIR)
1) Components Required
Component Qty

Arduino UNO 1

MQ135 Air Sensor 1

PIR Sensor 1

LED / Relay for Fan 1

2) Circuit Connections
Arduino Pin Connected To

A0 MQ135 Output

D7 PIR Output

D9 Fan / LED Output

3) Arduino Code (with Serial Output)


/*
* Auditorium Maintenance System
* Controls fan and lights based on air quality and presence
*/

#define MQ_PIN A0
#define PIR_PIN 7
#define FAN_PIN 9

void setup() {
[Link](9600);
pinMode(PIR_PIN, INPUT);
pinMode(FAN_PIN, OUTPUT);
[Link]("=== Auditorium System Started ===");
}

void loop() {
int air = analogRead(MQ_PIN);
int motion = digitalRead(PIR_PIN);

[Link]("Air Quality : " + String(air));


[Link]("Motion : " + String(motion));

if (air > 400) {


[Link]("Action : Fan ON (Poor Air)");
digitalWrite(FAN_PIN, HIGH);
} else if (motion == LOW) {
[Link]("Action : Fan OFF (No People)");
digitalWrite(FAN_PIN, LOW);
}

[Link]("-------------------");
delay(1000);
}

4) Expected Serial Output


=== Auditorium System Started ===
Air Quality : 512
Motion : 1
Action : Fan ON (Poor Air)
-------------------
Air Quality : 180
Motion : 0
Action : Fan OFF (No People)
-------------------

You might also like