/***************************************************************************
This code initializes the LCD display, RTC module, and NeoPixel strip in
the setup() function.
In the loop() function, it retrieves the current date and time from the RTC
module and displays it on the LCD display. It also calls two helper functions, chaseLights() and blinkLights(), which control the NeoPixel strip and two LEDs, respectively.
The chaseLights() function uses a for loop to cycle through each LED on
the strip and set its color to a random RGB value. It then shows the
updated strip and waits for a short period of time before moving on to
the next LED. The blinkLights() function blinks two LEDs connected to digital
pins 3 and 4 alternately. It turns on the red LED for 500 milliseconds,
then turns it off and turns on the green LED for another 500 milliseconds
before the cycle repeats.Note: This is just a sample code and might need
some adjustments based on your specific hardware setup.
author arvind patil 28 march 2023
********************************************************************************/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
#include <Adafruit_NeoPixel.h>
#define PIN_LED 6
#define NUM_LEDS 24
LiquidCrystal_I2C lcd(0x27, 16, 2);
RTC_DS1307 rtc;
Adafruit_NeoPixel strip(NUM_LEDS, PIN_LED, NEO_GRB + NEO_KHZ800);
int redLed = 8;
int greenLed = 9;
void setup() {
lcd.init();
lcd.backlight();
Wire.begin();
rtc.begin();
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
strip.begin();
strip.show();
}
void loop() {
DateTime now = rtc.now();
lcd.setCursor(0, 0);
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.setCursor(0, 1);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
chaseLights();
blinkLights();
delay(500);
}
void chaseLights() {
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, random(0, 255), random(0, 255), random(0, 255));
strip.show();
delay(50);
}
}
void blinkLights() {
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
delay(500);
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
delay(500);
}