#include <WiFi.h>
Arduino_MultiWiFi
#include <WiFi.h> // Include the Wi-Fi library
#include <WiFiUdp.h> // Include the Wi-Fi UDP library
#include <NTPClient.h> // Include the NTPClient library
#include <LiquidCrystal.h> // Include the LiquidCrystal library
// Replace these with your WiFi credentials
const char* ssid = "your-ssid";
const char* password = "your-password";
// Replace this with your NTP server address
const char* ntpServer = "pool.ntp.org";
// Define NTP client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, ntpServer);
// Define pins for LCD display
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Define pin for buzzer
const int buzzerPin = 10;
void setup() {
// Initialize Serial Monitor
Serial.begin(9600);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to WiFi");
// Initialize LCD display
lcd.begin(16, 2);
lcd.clear();
// Initialize NTP client
timeClient.begin();
timeClient.setTimeOffset(3600); // Time zone offset (in seconds)
}
void loop() {
timeClient.update();
// Get current time
unsigned long epochTime = timeClient.getEpochTime();
struct tm * ptm = gmtime ((time_t *)&epochTime);
int hour = ptm->tm_hour;
int minute = ptm->tm_min;
// Display current time on LCD
lcd.setCursor(0, 0);
lcd.print("Time: ");
if(hour < 10) lcd.print("0");
lcd.print(hour);
lcd.print(":");
if(minute < 10) lcd.print("0");
lcd.print(minute);
// Check if it's time to trigger the alarm (e.g., 7:00 AM)
if(hour == 7 && minute == 0) {
triggerAlarm();
}
delay(1000); // Update every second
}
void triggerAlarm() {
// Sound the buzzer
tone(buzzerPin, 1000);
delay(5000); // Buzz for 5 seconds
noTone(buzzerPin);
} // Include the Wi-Fi library
#include <WiFiUdp.h> // Include the Wi-Fi UDP library
#include <NTPClient.h> // Include the NTPClient library
#include <LiquidCrystal.h> // Include the LiquidCrystal library
// Replace these with your WiFi credentials
const char* ssid = "your-ssid";
const char* password = "your-password";
// Replace this with your NTP server address
const char* ntpServer = "pool.ntp.org";
// Define NTP client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, ntpServer);
// Define pins for LCD display
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Define pin for buzzer
const int buzzerPin = 10;
void setup() {
// Initialize Serial Monitor
Serial.begin(9600);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to WiFi");
// Initialize LCD display
lcd.begin(16, 2);
lcd.clear();
// Initialize NTP client
timeClient.begin();
timeClient.setTimeOffset(3600); // Time zone offset (in seconds)
}
void loop() {
timeClient.update();
// Get current time
unsigned long epochTime = timeClient.getEpochTime();
struct tm * ptm = gmtime ((time_t *)&epochTime);
int hour = ptm->tm_hour;
int minute = ptm->tm_min;
// Display current time on LCD
lcd.setCursor(0, 0);
lcd.print("Time: ");
if(hour < 10) lcd.print("0");
lcd.print(hour);
lcd.print(":");
if(minute < 10) lcd.print("0");
lcd.print(minute);
// Check if it's time to trigger the alarm (e.g., 7:00 AM)
if(hour == 7 && minute == 0) {
triggerAlarm();
}
delay(1000); // Update every second
}
void triggerAlarm() {
// Sound the buzzer
tone(buzzerPin, 1000);
delay(5000); // Buzz for 5 seconds
noTone(buzzerPin);
}