0% found this document useful (0 votes)
6 views16 pages

EX - NO:01 Led Blink Pattern Using Arduino or Raspberry Pi

The document outlines various projects using Arduino and Raspberry Pi, including LED blinking patterns, temperature monitoring with an LM35 sensor, forest fire detection, home intrusion detection, and home automation with NodeMCU. Each project includes aims, required components, procedures, programming code, outputs, and results. The projects demonstrate practical applications of IoT and microcontrollers in real-world scenarios.

Uploaded by

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

EX - NO:01 Led Blink Pattern Using Arduino or Raspberry Pi

The document outlines various projects using Arduino and Raspberry Pi, including LED blinking patterns, temperature monitoring with an LM35 sensor, forest fire detection, home intrusion detection, and home automation with NodeMCU. Each project includes aims, required components, procedures, programming code, outputs, and results. The projects demonstrate practical applications of IoT and microcontrollers in real-world scenarios.

Uploaded by

abiaravind1525
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

EX.

NO:01 LED BLINK PATTERN USING ARDUINO OR RASPBERRY PI

AIM:
To create an application to blink an LED and display different LED patterns using Arduino or
Raspberry Pi.

PROCEDURE:
1. Hardware Requirements:
 Arduino UNO or Raspberry Pi
 Breadboard
 LED
 Resistor (220Ω)
 Jumper wires
2. Circuit Setup:
 Connect the positive (long) leg of the LED to a digital pin (e.g., GPIO 17 for Raspberry
Pi or pin 13 for Arduino).
 Connect the negative leg to GND through a resistor.
3. Programming:
 Use Python with GPIO libraries (for Raspberry Pi) or Arduino IDE (for Arduino) to
blink the LED.
 Add multiple blink patterns such as fast blink, slow blink, or sequence.

PROGRAM:
Arduino version:
void setup() {
pinMode(13, OUTPUT); // Set pin 13 as output
}

void loop() {
digitalWrite(13, HIGH); // Turn LED ON
delay(500); // Wait for 0.5 second
digitalWrite(13, LOW); // Turn LED OFF
delay(500); // Wait for 0.5 second
}
RASPBERRY PI VERSION:
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)

while True:
GPIO.output(17, GPIO.HIGH)
time.sleep(0.5)
GPIO.output(17, GPIO.LOW)
time.sleep(0.5)

OUTPUT:
The LED will blink ON and OFF at 0.5-second intervals.

RESULT:
Successfully developed and executed an LED blinking and pattern application using
Raspberry Pi / Arduino.
EX.NO:02 LED PATTERN WITH PUSH BUTTON CONTROL

AIM:
To develop an application where LED blinking patterns are controlled using a push button on
Arduino or Raspberry Pi.

PROCEDURE:
1. Components Required:
o Arduino UNO / Raspberry Pi
o LED
o 220Ω Resistor
o Push Button
o Breadboard and Jumper Wires
2. Circuit Connection:
o Connect the LED anode to digital pin (D13 for Arduino / GPIO17 for Pi)
through a 220Ω resistor, cathode to GND.
o Connect one leg of the push button to a digital input pin (D2 for Arduino /
GPIO27 for Pi), and the other to GND.
o Use internal pull-up resistor for button input (in software).
3. Code Logic:
o Detect button press.
o On button press, change the blinking pattern of the LED (slow, fast, double
blink, etc.).
4. Execution:
o Upload the code to Arduino using Arduino IDE or run Python script on
Raspberry Pi.

PROGRAM:
Arduino version:
int buttonPin = 2;
int ledPin = 13;
int pattern = 0;

void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}

void loop() {
if (digitalRead(buttonPin) == LOW) {
pattern = (pattern + 1) % 3; // Cycle through 3 patterns
delay(300); // Debounce delay
}

if (pattern == 0) {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
} else if (pattern == 1) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
} else if (pattern == 2) {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
}
}
Raspberry Pi version:
import RPi.GPIO as GPIO
import time

led = 17
button = 27
pattern = 0

GPIO.setmode(GPIO.BCM)
GPIO.setup(led, GPIO.OUT)
GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def blink(pattern):
if pattern == 0:
GPIO.output(led, True)
time.sleep(1)
GPIO.output(led, False)
time.sleep(1)
elif pattern == 1:
GPIO.output(led, True)
time.sleep(0.2)
GPIO.output(led, False)
time.sleep(0.2)
elif pattern == 2:
GPIO.output(led, True)
time.sleep(0.1)
GPIO.output(led, False)
time.sleep(0.1)
try:
while True:
if GPIO.input(button) == False:
pattern = (pattern + 1) % 3
time.sleep(0.3) # Debounce
blink(pattern)
except KeyboardInterrupt:
GPIO.cleanup()

OUTPUT:
 LED blinks in different patterns.
 Each press of the button changes the pattern in sequence.

RESULT:
Successfully developed and tested an LED pattern application controlled by a push button on
Arduino/Raspberry Pi.
EX.NO:03 LM35 TEMPERATURE SENSOR TO DISPLAY TEMPERATURE VALUES

AIM:
To develop an application that reads temperature from an LM35 sensor and displays the
values on a serial monitor or terminal using Arduino or Raspberry Pi.

PROCEDURE:
1. Components Required:
 Arduino UNO / Raspberry Pi
 LM35 Temperature Sensor
 Breadboard and Jumper Wires
 (Optional: LCD display module for visual output)
2. Circuit Connection:
For LM35:
 VCC → 5V (Arduino) or 3.3V (Raspberry Pi)
 GND → GND
 OUT → A0 (Arduino) / GPIO pin with ADC (for Pi: use an ADC module like MCP3008)
3. Logic:
 Read analog voltage from sensor.
 Convert analog voltage to Celsius using formula:
o Temp(°C) = (Analog reading × 5.0 × 100) / 1024
4. Execution:
 Upload to Arduino using Arduino IDE.
 For Raspberry Pi, connect through MCP3008 (external ADC), use SPI to read analog
input.

PROGRAM:
Arduino version:
int sensorPin = A0;
float temp;
void setup() {
Serial.begin(9600);
}

void loop() {
int reading = analogRead(sensorPin);
temp = (reading * 5.0 * 100.0) / 1024.0;
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println(" °C");
delay(1000);
}

Raspberry Pi version:
import spidev
import time

spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 1350000

def read_channel(channel):
adc = spi.xfer2([1, (8+channel)<<4, 0])
data = ((adc[1]&3) << 8) + adc[2]
return data

def convert_temp(data):
volts = (data * 3.3) / 1024.0
temp = volts * 100
return temp

try:
while True:
reading = read_channel(0)
temperature = convert_temp(reading)
print(f"Temperature: {temperature:.2f} °C")
time.sleep(1)
except KeyboardInterrupt:
spi.close()

OUTPUT:
The temperature is printed on the serial monitor (Arduino) or terminal (Raspberry Pi) in °C,
updated every second.

RESULT:
Successfully developed a temperature monitoring application using LM35 sensor on
Arduino/Raspberry Pi, displaying real-time temperature data.
EX.NO:04 FOREST FIRE DETECTION END NODE USING ARDUINO OR RASPBERRY PI

AIM:
To develop an IoT-based application using Raspberry Pi and fire/smoke sensor to detect
forest fires and send real-time alerts.

PROCEDURE:
1. Components Required:
o Raspberry Pi (any model with GPIO)
o Fire Sensor / Smoke Sensor (like MQ-2 or Flame Sensor)
o Buzzer / LED (for alert indication)
o Jumper wires, Breadboard
o (Optional: Wi-Fi / SMS alert module or integration with cloud)
2. Connections:
o Connect the VCC of the fire/smoke sensor to 3.3V/5V on Pi
o GND to GND
o Digital output pin of the sensor to a GPIO pin (e.g., GPIO17)
o Connect buzzer or LED to another GPIO pin for alert
3. Logic:
o Continuously monitor sensor output
o If fire/smoke is detected, trigger alert (LED/Buzzer) and print/log message

PROGRAM:
Raspberry pi version:
import RPi.GPIO as GPIO
import time

sensor_pin = 17 # GPIO pin for fire sensor


buzzer_pin = 18 # GPIO pin for buzzer or LED
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor_pin, GPIO.IN)
GPIO.setup(buzzer_pin, GPIO.OUT)

try:
while True:
if GPIO.input(sensor_pin) == 0: # 0 = fire detected in some sensors
print("** ALERT: Fire Detected! **")
GPIO.output(buzzer_pin, GPIO.HIGH)
else:
print("No fire detected.")
GPIO.output(buzzer_pin, GPIO.LOW)
time.sleep(1)

except KeyboardInterrupt:
GPIO.cleanup()

OUTPUT:
 When the sensor detects smoke/fire, a message is printed:
"** ALERT: Fire Detected! **"
 Buzzer/LED is turned ON for visual/audio indication.
 When no fire is detected, it prints: "No fire detected."

RESULT:
Successfully implemented a forest fire detection end node using Raspberry Pi. The sensor
detects fire or smoke and triggers alerts through buzzer/LED and terminal output.

EX.NO:05 HOME INTRUSION DETECTION WEB APP


AIM:
To design a home intrusion detection system using Raspberry Pi and a motion sensor, with a
web interface to alert the user remotely.

PROCEDURE:
1. Components Required:
 Raspberry Pi
 PIR Motion Sensor (HC-SR501)
 Jumper wires
 LED or Buzzer
 Flask (for web interface)
2. Connections:
 PIR sensor VCC → 5V
 GND → GND
 OUT → GPIO17
 Connect LED/Buzzer to GPIO27 for alerts
3. Logic:
 Monitor motion using PIR sensor
 On detection, trigger buzzer and send update to web interface
4. Software Setup:
 Install Flask: pip install flask
 Host a simple Flask server to show intrusion status

PROGRAM:
from flask import Flask, render_template_string
import RPi.GPIO as GPIO
import time
import threading
app = Flask(__name__)

motion_pin = 17
alert = False

GPIO.setmode(GPIO.BCM)
GPIO.setup(motion_pin, GPIO.IN)

def detect_motion():
global alert
while True:
if GPIO.input(motion_pin):
alert = True
else:
alert = False
time.sleep(1)

@app.route('/')
def home():
status = "Intrusion Detected!" if alert else "All Clear"
return render_template_string("""
<h1>Home Security Status</h1>
<p>Status: <strong>{{ status }}</strong></p>
""", status=status)

if __name__ == '__main__':
t = threading.Thread(target=detect_motion)
t.daemon = True
t.start()
app.run(host='0.0.0.0', port=5000)

OUTPUT:
 The Flask web app displays the real-time intrusion status.
 Message like "Intrusion Detected!" appears when motion is sensed.

RESULT:
Successfully developed a home intrusion detection web application using Raspberry Pi and
PIR sensor with a real-time Flask web interface.

EX.NO:06 HOME AUTOMATION USING NODE MCU AND IOT CLOUD PLATFORM
AIM:
To develop a smart home automation system using NodeMCU and an IoT cloud platform like
Blynk or ThingSpeak to control devices remotely.

PROCEDURE:
1. Components Required:
 NodeMCU (ESP8266)
 Relay Module
 LED/Bulb or Appliance
 Jumper wires
 Blynk App (or alternative)
2. Connections:
 Connect relay IN to D1 (GPIO5)
 VCC → 3.3V
 GND → GND
 Connect LED or AC appliance to relay (with proper safety precautions)
3. Logic:
 Connect NodeMCU to Wi-Fi
 Use Blynk app to send ON/OFF commands
 Relay switches device accordingly
4. Software Setup:
 Install Blynk library in Arduino IDE
 Setup Blynk app and get authentication token

PROGRAM:
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "YourAuthToken"; // From Blynk app
char ssid[] = "YourWiFiSSID";
char pass[] = "YourWiFiPassword";

int relayPin = D1;

void setup() {
Serial.begin(9600);
pinMode(relayPin, OUTPUT);
Blynk.begin(auth, ssid, pass);
}

BLYNK_WRITE(V1) {
int pinValue = param.asInt();
digitalWrite(relayPin, pinValue);
}

void loop() {
Blynk.run();
}

OUTPUT:
 When you press the button on the Blynk app, the relay activates or deactivates the
device.
 Real-time control via cloud over Wi-Fi.

RESULT:
Successfully developed a smart home automation system using NodeMCU and IoT cloud
(Blynk) for remote control of home appliances.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy