Docsity

IOT Practical 9 code TE AIDS SPPU 2024 Pattern, Study Guides, Projects, Research of Internet and Information Access

Toggle sidebar
bg1
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 13
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
String password = "1234";
bool ok = false;
void setup() {
Serial.begin(9600);
sensors.begin();
Serial.println("Enter Password:");
}
void loop() {
if (Serial.available()) {
String input = Serial.readStringUntil('\n');
input.trim(); // removes \r, spaces
ok = (input == password);
if (ok)
Serial.println("ACCESS GRANTED ✔");
else
Serial.println("WRONG PASSWORD ");
}
if (ok) {
sensors.requestTemperatures();
Serial.print("Temp: ");
Serial.println(sensors.getTempCByIndex(0));
delay(2000);
}
}
OUTPUT:
pf2

Partial preview of the text

Download IOT Practical 9 code TE AIDS SPPU 2024 Pattern and more Study Guides, Projects, Research Internet and Information Access in PDF only on Docsity!

#include #include #define ONE_WIRE_BUS 13 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); String password = "1234"; bool ok = false; void setup() { Serial.begin(9600); sensors.begin(); Serial.println("Enter Password:"); } void loop() { if (Serial.available()) { String input = Serial.readStringUntil('\n'); input.trim(); // removes \r, spaces ok = (input == password); if (ok) Serial.println("ACCESS GRANTED ✔"); else Serial.println("WRONG PASSWORD "); } if (ok) { sensors.requestTemperatures(); Serial.print("Temp: "); Serial.println(sensors.getTempCByIndex(0)); delay(2000); } }

OUTPUT: