Lab File
Cloud Based Internet of Things
Systems
R1UC605C (PR)
2023-24
SCHOOL OF COMPUTING SCIENCE
AND ENGINEERING
SUBMITTED BY : SUBMITTED TO :
Faizan Parvez Mr. Hradesh Kumar
Dr Ajay Shanker Singh
21SCS1050002
INDEX
Galgotias UNIVERSITY
Student Name:….……………………
Roll No:……………………….
Course: Cloud Based Internet of Things Systems R1UC605C (PR)
Assessment by Faculty Member
Date of Page Pre- Implime In time
Exp Name Of the Experiment Prac No. Fro Lab ntaion Output Submissi Total Signature
No. tical m…. Writi MM: 10 cal. on of Lab MM: with Date
To… ng MM: 05 report/ 25
work viva
MM voice,
: 05 MM:
05
1 Study of Arduino IDE and Raspbian OS,
Installation of OS on IoT kit.
2 Study on AWS, AZURE and GOOGLE
Cloud
3 Led with buzzer, PIR with buzzer
4 Light sensor with led and display
5 LCD display of all types of sensors
6 Combination of different uno with
display and sensor
7 Basic cloud security model connecting
IoT devices in thinkercad.
8 Authentication based program to
identify the user
9 Http local sever is ESP32, Sensor Live
logger in ESP32
10 Sensor Feed in Live HIVE cloud using
MQTT, working with Pico
11 Pico and sensor connection, Pico and
ES32 with OLED and other display
devices.
12 Creating an S3 Bucket, uploading a File
to S3
13 Launching an EC2 Instance, Configuring
Security Groups.
14 Using AWS CLI, Monitoring Resources
15 Smart City , Smart Water
16 Smart Agriculture, Smart Energy
17 Smart Healthcare , Smart Transportation
18 Smart Retail
19 Smart waste management. Soil moisture
sensor with Arduino IoT cloud
20 IOT Smart Plant Monitoring System
Teacher Remark(If any): AVERAGE MARKS:……….
Sign Of Faculty Members:
Experiment 1
Objective: . 4 Led with musical blinking and buzzer connected and
also connect push button.
Circuit Diagram:
Code
const int buttonPin = 13;
const int ledPin = 9;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
int currentState = digitalRead(buttonPin);
if (currentState == LOW) {
3
digitalWrite(ledPin, HIGH);
}
else if (currentState == HIGH) {
digitalWrite(ledPin, LOW);
}
delay(50);
}
Output of Experiment 1
4
Experiment 2
Objective: Connect Arduino with Motion Sensor with Distance
sensor with Alert system.
Circuit Diagram:
Code
int led = 13;
int sensor = 2;
int state = LOW;
int val = 0;
void setup() {
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600);
5
}
void loop(){
val = digitalRead(sensor);
if (val == HIGH) {
digitalWrite(led, HIGH);
delay(10);
if (state == LOW) {
Serial.println("Motion detected!");
state = HIGH;}
}
else {
digitalWrite(led, LOW);
delay(10);
if (state == HIGH){
Serial.println("Motion stopped!");
state = LOW;
}
}
}
Output of Experiment 2
6
Experiment 3
Objective: Connect Arduino for Home automation with
Temperature Sensor with Motor & LDR with light working and additionally
LCD display
Circuit Diagram:
Code
int ldrPin = A0; // LDR pin
int ldrVal = 0;
// Value of LDR
int ledPin = 2; // Build in LED pin
const float GAMMA = 0.7;
const float RL10 = 50;
void setup() {
Serial.begin(9600); // Initialise the serial monitor
pinMode(2, OUTPUT);
}
void loop() {
ldrVal = analogRead(ldrPin); // Read the analog value of the LDR
float voltage = ldrVal / 1024. * 5;
float resistance = 2000 * voltage / (1 - voltage / 5);
float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
if (lux < 200) {
7
// If the LDR value is lower than 200
digitalWrite(ledPin, HIGH); // Turn buildin LED on
} else {
digitalWrite(ledPin, LOW); // Turn buildin LED off
}
Serial.println(lux);
// Show the value in the serial monitor
delay(1000);
// Pause 1000ms
}
Output of Experiment 3
8
Experiment 4
Objective: Connect Arduino with RGB Led with Soil moisture
sensor and display with LCD start motor on dry values.
Circuit Diagram:
Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int moisturePin = A0;
int blueLedPin = 8;
int orangeLedPin = 9;
int redLedPin = 7;
int buzzerPin = 10;
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(blueLedPin, OUTPUT);
pinMode(orangeLedPin, OUTPUT);
9
pinMode(redLedPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(A0, INPUT);
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("Moisture:");
lcd.setCursor(0, 1);
lcd.print("Status: ");
float moistureValue = analogRead(0);
lcd.setCursor(10, 0);
lcd.print(moistureValue);
if (moistureValue > 500) {
digitalWrite(blueLedPin, HIGH);
digitalWrite(orangeLedPin, LOW);
digitalWrite(redLedPin, LOW);
noTone(buzzerPin);
lcd.setCursor(8, 1);
lcd.print("WET ");
} else if (moistureValue >= 151 && moistureValue <= 499) {
digitalWrite(blueLedPin, LOW);
digitalWrite(orangeLedPin, HIGH);
digitalWrite(redLedPin, LOW);
noTone(buzzerPin);
lcd.setCursor(8, 1);
lcd.print("NORMAL");
} else {
digitalWrite(blueLedPin, LOW);
digitalWrite(orangeLedPin, LOW);
digitalWrite(redLedPin, HIGH);
tone(buzzerPin, 1000);
lcd.setCursor(8, 1);
lcd.print("DRY ");
}
delay(500);
}
10
Output of Experiment 4
11
Experiment 5
Objective: Develop a progress bar with the connection of any
sensor to display the live status with LCD using Arduino in Wowki.
Circuit Diagram:
Code
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
dht.begin();
12
lcd.init();
// print a message to the LCD
lcd.backlight();
lcd.setCursor(2,3);
lcd.print("Lernfeld LF07-V2");
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
lcd.setCursor(3,0);
lcd.print("Messung laeuft");
lcd.setCursor(0,1);
lcd.print("Temperatur: "+String(t,1) +" C");
lcd.setCursor(0,2);
lcd.print("Feuchtigkeit: "+String(h,1) + " %");
}
13
Output of Experiment 5
14
Experiment 6
Objective: Create a Waste management system with the LCD
display in WoWk.
Circuit Diagram:
Code
#define BLYNK_TEMPLATE_ID "TMPL2OeXhA_I2"
#define BLYNK_TEMPLATE_NAME "Smart Waste Management System"
#define BLYNK_AUTH_TOKEN "JXuTLg6wGCIFoQpEoYzRzgWtFwD1LD9s"
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp32.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <ESP32Servo.h>
#define Second 1000
#define Dry_Echo 18
15
#define Dry_Trig 19
#define Wet_Echo 22
#define Wet_Trig 23
#define SoilMoisture 33
#define ServoMotor 21
// functions
void send_blynk();
float calculate_distance(int Trig, int Echo, char can);
bool is_full(int Trig, int Echo, char can);
float calibrate(int moisture);
// global variables
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
bool dry_full = 0;
bool wet_full = 0;
int servo_pos = 90;
int max_moisture = 4095;
int min_moisture = 1095;
float threshold = calibrate(1000);
BlynkTimer timer;
Servo servo;
void setup() {
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
pinMode(Dry_Trig, OUTPUT);
pinMode(Dry_Echo, INPUT);
pinMode(Wet_Trig, OUTPUT);
pinMode(Wet_Echo, INPUT);
pinMode(SoilMoisture, INPUT);
servo.attach(ServoMotor, 500, 2400);
timer.setInterval(1000, send_blynk);
}
void loop() {
Serial.println(" ");
// manage trash
int moisture_value = analogRead(SoilMoisture);
float moisture = calibrate(moisture_value);
Serial.print("Moisture : ");
16
Serial.print(moisture_value);
Serial.print(" ----> calibrated : ");
Serial.print(moisture);
Serial.println("%");
bool dry_trash = moisture > threshold;
if(dry_trash){
Serial.print("The trash is dry (threshold = ");
Serial.print(threshold);
Serial.println("%)");
// open gate
for (servo_pos = 90; servo_pos >= 0; servo_pos -= 1) {
servo.write(servo_pos);
delay(15);
}
delay(5 * Second);
// close gate
for (servo_pos = 0; servo_pos <= 90; servo_pos += 1) {
servo.write(servo_pos);
delay(15);
}
}
bool wet_trash = moisture < threshold;
if(wet_trash){
Serial.print("The trash is wet! (threshold = ");
Serial.print(threshold);
Serial.println("%)");
// open gate
for (servo_pos = 90; servo_pos >= 0; servo_pos -= 1) {
servo.write(servo_pos);
delay(15);
}
delay(5 * Second);
// close gate
for (servo_pos = 0; servo_pos <= 90; servo_pos += 1) {
servo.write(servo_pos);
delay(15);
}
17
}
// manage can
dry_full = is_full(Dry_Trig, Dry_Echo, 'D');
wet_full = is_full(Wet_Trig, Wet_Echo, 'W');
if (dry_full){
Serial.println("The dry can is full.");
}
if (wet_full){
Serial.println("The wet can is full.");
}
Blynk.run();
timer.run();
delay(10 * Second);
}
void send_blynk(){
if (wet_full){
Blynk.logEvent("wet_can_is_full") ;
Blynk.virtualWrite(V1, 1);
}else{
Blynk.virtualWrite(V1, 0);
}
if (dry_full){
Blynk.logEvent("dry_can_is_full") ;
Blynk.virtualWrite(V0, 1);
}else{
Blynk.virtualWrite(V0, 0);
}
}
float calculate_distance(int Trig, int Echo, char can){
digitalWrite(Trig, LOW);
delay(2);
digitalWrite(Trig, HIGH);
delay(10);
digitalWrite(Trig, LOW);
int duration = pulseIn(Echo, HIGH);
float distance = duration * 0.034 /2;
Serial.print(can);
18
Serial.print(" free space : ");
Serial.print(distance);
Serial.println(" CM");
return distance;
}
bool is_full(int Trig, int Echo, char can){
float distance = calculate_distance(Trig, Echo, can);
return distance < 4;
}
float calibrate(int moisture){
int x = (max_moisture - min_moisture)/100;
return (max_moisture - moisture)/x;
}
Output
19
Experiment 7
Objective: Develop a live Weather display to fetch from free API
avaliable online in WoWki
Circuit Diagram:
Code
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <Arduino_JSON.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
20
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset
pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire,
OLED_RESET);
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const char* weatherAPIKey = "ee6ba6810020699060c2af52ff377857";
const char* weatherAPIURL =
"http://api.openweathermap.org/data/2.5/weather?q=Mumbai,IN,&appid=";
void setup() {
Serial.begin(115200);
delay(2000); // Delay for serial connection to be established
Serial.println("Connecting to WiFi...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting...");
}
Serial.println("Connected to WiFi");
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
}
void loop() {
display.clearDisplay();
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = String(weatherAPIURL) + String(weatherAPIKey);
http.begin(url);
int httpResponseCode = http.GET();
if (httpResponseCode > 0) {
String payload = http.getString();
21
JSONVar data = JSON.parse(payload);
double temperature = data["main"]["temp"];
temperature -= 273.15; // Convert from Kelvin to Celsius
display.setCursor(0, 0);
display.print("Temperature: ");
display.print(temperature);
display.print(" C");
} else {
display.setCursor(0, 0);
display.println("Error getting weather");
}
http.end();
} else {
display.setCursor(0, 0);
display.println("WiFi Disconnected");
}
display.display();
delay(30000); // Delay for 30 seconds before fetching weather again
}
22
Output of Experiment 7
23
Experiment 8
Objective: Develop a live Weather display to fetch from free API
avaliable online in WoWki
Circuit Diagram:
Code
import network
import time
from machine import Pin
import dht
import ujson
from umqtt.simple import MQTTClient
# MQTT Server Parameters
MQTT_CLIENT_ID = "micropython-weather-demo"
MQTT_BROKER = "broker.mqttdashboard.com"
MQTT_USER = ""
MQTT_PASSWORD = ""
MQTT_TOPIC = "wokwi-weather"
sensor = dht.DHT22(Pin(15))
print("Connecting to WiFi", end="")
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('Wokwi-GUEST', '')
24
while not sta_if.isconnected():
print(".", end="")
time.sleep(0.1)
print(" Connected!")
print("Connecting to MQTT server... ", end="")
client = MQTTClient(MQTT_CLIENT_ID, MQTT_BROKER, user=MQTT_USER,
password=MQTT_PASSWORD)
client.connect()
print("Connected!")
prev_weather = ""
while True:
print("Measuring weather conditions... ", end="")
sensor.measure()
message = ujson.dumps({
"temp": sensor.temperature(),
"humidity": sensor.humidity(),
})
if message != prev_weather:
print("Updated!")
print("Reporting to MQTT topic {}: {}".format(MQTT_TOPIC, message))
client.publish(MQTT_TOPIC, message)
prev_weather = message
else:
print("No change")
time.sleep(1)
25
Output of Experiment 8
26
Experiment 9
Objective: Create a Smart Agriculture monitoring system using
either Pi or Arduino in Wowki/Thinkercad
Circuit Diagram:
Code
// C++ code
//
int soil_sensor = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
void loop()
{
soil_sensor = analogRead(A0);
Serial.println(soil_sensor);
27
if (soil_sensor < 100) {
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
} else {
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}
Output of Experiment 9
28
Experiment 10
Objective: Create a Smart Industry/Healthcare monitoring system
using either Pi or Arduino in Wowki/Thinkercad
Circuit Diagram:
Code
#include <LiquidCrystal.h>
// only on pressing the buttons you can start measurement.
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
float voltage;
int celsius;
int valPulse;
int pulsePin = A2;
const int temperaturePin = A0;
String seconds;
long duration;
float BMI2;
int buzzerpin = 2,button_1=A3,button_2=A4,button_3=A5,button_4 = 4;
int pir_sensor = 7, triggerPin = 5, echoPin = 6, triggerpin_2 = 4, echopin_2 =
3;
int pir_reader, time, distance;
int minDistance = 100;
int maxDistance = 400;
29
float height2 ;
float weightKG ;
void setup()
{
pinMode(temperaturePin, INPUT);
pinMode(button_1,INPUT);
pinMode(button_2,INPUT);
pinMode(button_3,INPUT);
pinMode(button_4,INPUT);
lcd.begin(16, 2);
Serial.begin(9600);
lcd.print("SMART HEALT PROJECT");
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.println("HEALTH MONITORING");
lcd.setCursor(0, 2);
lcd.print("SYSTEM");
delay(3000);
lcd.clear();
pinMode(7, INPUT);
pinMode(triggerPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzerpin,OUTPUT);
pinMode(triggerpin_2, OUTPUT);
pinMode(echopin_2, INPUT);
}
void loop()
{
if(digitalRead(button_1)== HIGH)
{
lcd.clear();
lcd.print("Calculating ......... ");delay(7000);
voltage = analogRead(temperaturePin) * 0.004882814;
celsius = (voltage - 0.5) * 100.0;
lcd.clear();
lcd.print("Body Temp. : ");
lcd.print(celsius);
lcd.print("C");delay(3000);
if(celsius>38)
{ lcd.clear();
digitalWrite(buzzerpin, HIGH);
lcd.print("High temp");
delay(4000);
digitalWrite(buzzerpin, LOW);
30
}
else
{
lcd.clear();
lcd.print("Normal Temp");
delay(4000);
}
lcd.clear();
for (int i=3; i >= 0; i--){
seconds = String(i);
lcd.print("PLEASE HOLD.." + seconds);
lcd.setCursor(0, 1);
lcd.print("BPM: ");
valPulse = analogRead(pulsePin);
valPulse = valPulse/6;
lcd.print(valPulse);
lcd.print(" Pulse");
lcd.print(" ");
delay(1000);
lcd.clear();
}
lcd.print("Temperature:");lcd.print(celsius);lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Pulse : ");lcd.print(valPulse);
while(digitalRead(button_1)== 0);
delay(250);
lcd.clear();
}
if(digitalRead(button_2)== HIGH)
{
//Print the Values on LCD
Serial.println("Enter your height in cm");
lcd.print("Enter your");lcd.setCursor(0, 1);
lcd.print("Height in cm");
while (Serial.available()==0){} //Wait for user input
lcd.clear();
height2 = Serial.parseFloat();
lcd.print ("Height: ");
lcd.print (height2);
lcd.print ("cm");
delay(4000);
lcd.clear();
Serial.println("Enter your Weight in KGs");
lcd.print("Enter your");lcd.setCursor(0, 1);
lcd.print("Weight in Kg");
31
while (Serial.available()==0){} //Wait for user input
lcd.clear();
weightKG = Serial.parseFloat();
lcd.print("Weight: ");
lcd.print(weightKG);
lcd.print ("kg");
delay(4000);
lcd.clear();
BMI2= weightKG/(height2*height2);
BMI2= BMI2*10000;
lcd.clear();
lcd.print("BMI: ");
lcd.print(BMI2,4);
//Categorizing BMI
if (BMI2<18.5){
lcd.setCursor(1, 1);
lcd.print("UNDERWEIGHT");
delay(4000);
}
else if (BMI2>18.5&&BMI2<25){
lcd.setCursor(1, 1);
lcd.print("NORMAL");
delay(4000);
}
else if (BMI2>=25&&BMI2<30){
lcd.setCursor(1, 1);
lcd.print("OVERWEIGHT");
delay(4000);
}
else if (BMI2>=30&&BMI2<35){
lcd.setCursor(1, 1);
lcd.print("MODERATELY");
lcd.print("OVERWEIGHT");
delay(4000);
}
else if (BMI2>=35){
lcd.setCursor(1, 1);
lcd.print("SEVERELY");
lcd.print("OBESE");
delay(4000);
}
while(digitalRead(button_2)==0);
delay(500);
lcd.clear();
}
32
if(digitalRead(button_3)== HIGH)
{
delay(150);
while(1)
{
// Duration will be the input pulse width and distance will be the
distance to the obstacle in centimeters
int duration, distance;
// Output pulse with 1ms width on trigPin
digitalWrite(triggerPin, HIGH);
delay(100);
digitalWrite(triggerPin, LOW);
// Measure the pulse input in echo pin
duration = pulseIn(echoPin, HIGH);
if(digitalRead(button_3)==HIGH){lcd.clear();digitalWrite(buzzerpin,
LOW);break;}
// Distance is half the duration devided by 29.1 (from datasheet)
distance = (duration/2) / 29.1;
// if distance less than 0.5 meter and more than 0 (0 or less means over
range)
if (distance <= 100 && distance >= 0)
{
// Buzz
if(digitalRead(button_3)==HIGH){lcd.clear();digitalWrite(buzzerpin,
LOW);break;}
lcd.setCursor(0,0);
lcd.print("Human");
lcd.setCursor(0,1);
lcd.print("Detected ");
digitalWrite(buzzerpin, HIGH);
}
else
{
// Don't buzz
if(digitalRead(button_3)==HIGH){lcd.clear();digitalWrite(buzzerpin,
LOW);break;}
lcd.setCursor(0,0);
lcd.print("Human");
lcd.setCursor(0,1);
lcd.print("Not Detected");
digitalWrite(buzzerpin, LOW);
}
// Waiting 60 ms won't hurt any one
if(digitalRead(button_3)==HIGH){lcd.clear();digitalWrite(buzzerpin,
LOW);break;}
delay(40);
33
if(digitalRead(button_3)==HIGH){lcd.clear();digitalWrite(buzzerpin,
LOW);break;}
}
delay(250);
/*while(1)
{
pir_reader = digitalRead(pir_sensor);
if (pir_reader == HIGH)
{
// Duration will be the input pulse width and distance will be the distance
to the obstacle in centimeters
int duration, distance;
// Output pulse with 1ms width on trigPin
digitalWrite(triggerPin, HIGH);
delay(100);
digitalWrite(triggerPin, LOW);
// Measure the pulse input in echo pin
duration = pulseIn(echoPin, HIGH);
// Distance is half the duration devided by 29.1 (from datasheet)
distance = (duration/2) / 29.1;
// pir_reader = digitalRead(pir_sensor);
// if distance less than 0.5 meter and more than 0 (0 or less means over
range)
if (distance <= 100 && distance >= 0)
{
// Buzz
digitalWrite(buzzerpin, HIGH);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("AlARM BUZZES");
//delay(3000);
lcd.setCursor(0,1);
lcd.print("Not safe");
delay(5000);
digitalWrite(buzzerpin, LOW);
}
else
{
// Don't buzz
digitalWrite(buzzerpin, LOW);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("NO ALARM");
//delay(3000);
34
lcd.setCursor(0,1);
lcd.print(" safe");
delay(5000);
lcd.clear();
}
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("No Human");
lcd.setCursor(0,1);
lcd.print("Detected");
}
*/
//}
//3rd loop ends
if(digitalRead(button_4)== HIGH)
{
while(1){
//medicine reminder
Serial.println("(hours) : ");
while (Serial.available()==0){}
long int hours = Serial.parseInt();
lcd.print(hours);
lcd.print(" : ");
Serial.println("(minutes) : ");
while (Serial.available()==0){}
long int mins = Serial.parseInt();
lcd.print(mins);
lcd.print(" : ");
Serial.println("(seconds) : ");
while (Serial.available()==0){}
long int seconds = Serial.parseInt();
lcd.print(seconds);
lcd.clear();
long int current_time =(hours*3600)+(mins*60)+(seconds);
lcd.print(current_time);
delay(3000);
lcd.clear();
long int i;
35
for(i= current_time ; i< (current_time+(86400)); i++){
if(i == 28800){ //8 am
digitalWrite(buzzerpin,HIGH);
tone(buzzerpin, 100 ); // Send 1KHz sound signal...
lcd.print("Medicine time");
delay(5000);
lcd.clear();
digitalWrite(buzzerpin,LOW);
}
else if(i == 72000){//8 pm
digitalWrite(buzzerpin,HIGH);
tone(buzzerpin, 100); // Send 1KHz sound signal...
lcd.print("Medicine time");
delay(5000);
lcd.clear();
digitalWrite(buzzerpin,LOW);
}
else{
lcd.setCursor(0,0);
lcd.print("Your medicine");
lcd.setCursor(0,1);
lcd.print("time is after :");
delay(1000);
if(i<28800 ){
lcd.clear();
lcd.setCursor(0,0);
lcd.print(28800-i );
lcd.setCursor(0,1);
lcd.print("seconds");
delay(1000);
lcd.clear();
}
else if (i>28000 && i<72000){
lcd.clear();
lcd.setCursor(0,0);
lcd.print( 72000-i);
lcd.setCursor(0,1);
lcd.print("seconds");
delay(1000);
lcd.clear();
}
else if (i>72000){
lcd.clear();
36
lcd.setCursor(0,0);
lcd.print( 86400-i + 28800);
lcd.setCursor(0,1);
lcd.print("seconds");
delay(2000);
lcd.clear();
}
}
}
}
}
}
Output of Experiment 10
37
38