IoT Lab Mid Suggestion
IoT Lab Mid Suggestion
IoT Lab Mid Suggestion
<=============DISTANCE Measurement==========>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
void setup() {
// Initialize Serial communication for debugging (optional)
Serial.begin(9600);
void loop() {
// Clear the trigger pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Send a 10us pulse to trigger the ultrasonic sensor
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
if (distance<10){
digitalWrite(buzzerPin, HIGH);
}else{
digitalWrite(buzzerPin, LOW);
}
lcd.print(distance);
lcd.print(" cm");
delay(500); // Delay to update the LCD display every 0.5 seconds
lcd.clear();
Architecture:
<=====================Temperature Measurement ===================>
#include <DHT.h>
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
delay(2000); // Wait for 2 seconds between measurements
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
} else {
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}
}
Architecture:
<================LCD DISPLAY===============>
// Initialize the LCD with the I2C address (0x27 for a common address)
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change the numbers for your specific LCD size
void setup() {
// Initialize the LCD
lcd.init();
void loop() {
// Nothing to do here in this simple example
}
<========================LCD display============>
#include <Arduino.h>
#include <LiquidCrystal_I2C.h>
void setup() {
// Initialize the LCD display
lcd.init();
void loop() {
// Delay for 100 milliseconds
delay(100);
}
Architecture:
void setup() {
// Set the keypad row pins as output
for (int i = 0; i < 4; i++) {
pinMode(KEYPAD_ROWS[i], OUTPUT);
}
void loop() {
// Read the keypad
char key = readKeypad();
// No key is pressed
return '\0';
}
Architecture:
digitalWrite(LED, LOW);
delay(5000);
}
Architecture: