Rishifile
Rishifile
INTERNET OF THINGS
PRACTICAL FILE
SUBJECT CODE – BCA(372)
2) Write the Steps to Add Libraries in Arduino and Setup Arduino IDE 06
for Programming.
10) Write a program for controlling bulb on/off by using Blynk app.
22
Q-1: Study and Install IDE of Arduino.
3. Install Drivers
Ensure the option to install drivers is checked to allow your computer to recognize the
Arduino board.
4. Complete Installation
Once done, launch the Arduino IDE.
For macOS:
1. Open the Disk Image
Double-click the downloaded .dmg file to open it.
2. Drag to Applications
Drag the Arduino IDE icon into your Applications folder.
For Linux:
1. Extract the Archive
Locate the .tar.xz file and extract it using a file manager or terminal.
2. Run the IDE
Navigate to the extracted folder in the terminal and run the IDE by executing
./arduino.
3. Install Dependencies
Install additional required packages as specified in the README file included in the
extracted folder.
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED on
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, LOW); // Turn the LED off
delay(1000); // Wait for a second
}
• Documentation
Check the Arduino Reference for detailed information on functions and libraries.
• Community
Join the Arduino community forums and explore online tutorials to expand your
skills.
Q-2: Write the Steps to Add Libraries in Arduino and Setup Arduino IDE for
Programming.
3. Install a Library
o Select the desired library and click the Install button. The library will be
automatically added to your Arduino IDE.
▪ Windows: Documents\Arduino\libraries
▪ macOS: Documents/Arduino/libraries
▪ Linux: ~/Arduino/libraries
3. Monitor Output
o Use the Serial Monitor (found under Tools > Serial Monitor) to view any
output from your Arduino, especially if the library involves serial
communication.
Q-3: Write a Program using Arduino for Blink LED.
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
Q-4: Write a Program for monitoring Temperature using Arduino and LM35
Temperature Sensor.
Components Needed
• Arduino Board (e.g., Arduino Uno)
Circuit Connection
1. LM35 Connections:
Arduino Code
const int lm35Pin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(lm35Pin);
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
delay(1000);
}
Q-5: Write a Program for Controlling Raspberry Pi with WhatsApp
import network
import requests
from time import sleep
import os
# Wi-Fi credentials
ssid = 'REPLACE_WITH_YOUR_SSID'
password = 'REPLACE_WITH_YOUR_PASSWORD'
# Main execution
try:
if init_wifi(ssid, password): # Connect to Wi-Fi
while True:
# Simulate command retrieval (replace with actual logic for reading commands
from WhatsApp)
command = "status" # Replace this with dynamic command retrieval
response = check_command(command) # Execute the command
send_message(phone_number, api_key, response) # Send response via WhatsApp
sleep(10) # Delay before checking the next command
except Exception as e:
print(f'Error: {e}')
Q-6: Write a Program to shows how to Fade an LED on pin9 using the analog Write()
function.
// Define the pin where the LED is connected
const int ledPin = 9; // LED connected to pin 9
void setup() {
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Fade in from 0 to 255
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(ledPin, brightness); // Set the brightness of the LED
delay(10); // Wait for 10 milliseconds to see the fade effect
}
http://arduino.esp8266.com/stable/package_esp8266com_index.json
4. Click OK.
5. Navigate to Tools > Board > Boards Manager.
6. Search for ESP8266 and install the package ESP8266 by ESP8266 Community.
1. Download and install the Blynk App on your smartphone (available for both Android
and iOS).
2. Sign up or log in using your email address.
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
void loop() {
Blynk.run(); // Run Blynk
3. Select the correct Board (NodeMCU 1.0) and Port from the Tools menu.
http://blynk-cloud.com/YourAuthToken/update/D2
▪ Method: GET
Step-by-Step Explanation
1. Header Files:
o #include <ESP8266WiFi.h> and #include <BlynkSimpleEsp8266.h> are
included to enable Wi-Fi connectivity and interaction with the Blynk platform.
4. Setup Function:
o Initializes the serial communication and connects to Blynk using
Blynk.begin(auth, ssid, pass);.
Complete Code
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(ledPin, OUTPUT);
}
BLYNK_WRITE(V1) {
int brightness = param.asInt(); // Get slider value from Blynk (0 -1023)
analogWrite(ledPin, brightness); // Adjust LED brightness
}
void loop() {
Blynk.run(); // Keep Blynk connected
}
Q-9: Write a program for Arduino by using Ultrasonic Sensor and Servo Motor (HC-
SR04), and make a smart dustbin.
#include <Servo.h>
// Define Servo
Servo dustbinLid;
const int servoPin = 6;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
dustbinLid.attach(servoPin);
dustbinLid.write(0); // Start with lid closed
void loop() {
long duration;
int distance;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH); // Default: Relay OFF (Normally Open)
}
BLYNK_WRITE(V1) {
int value = param.asInt(); // Read button value (0 or 1)
digitalWrite(relayPin, value ? LOW : HIGH); // Turn ON/OFF relay
}
void loop() {
Blynk.run(); // Keep Blynk connected
}