Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #include <Wire.h>
- #include <RTClib.h>
- RTC_DS1307 RTC; // Establishes the chipset of the Real Time Clock
- #define LEDStripPin 6 // Pin used for the data to the LED strip
- #define menuPin A3 // Pin used for the menu button (green stripe)
- #define numLEDs 60 // Number of LEDs in strip
- struct CRGB leds[numLEDs];
- int LEDOffset = 30;
- void setup()
- {
- // Start LEDs
- FastLED.addLeds<NEOPIXEL, LEDStripPin>(leds, numLEDs);
- Wire.begin();
- RTC.begin();
- Serial.begin(9600);
- DateTime now = RTC.now();
- Serial.print("Hour time is... ");
- Serial.println(now.hour());
- Serial.print("Min time is... ");
- Serial.println(now.minute());
- Serial.print("Sec time is... ");
- Serial.println(now.second());
- Serial.print("Year is... ");
- Serial.println(now.year());
- Serial.print("Month is... ");
- Serial.println(now.month());
- Serial.print("Day is... ");
- Serial.println(now.day());
- }
- void loop()
- {
- DateTime now = RTC.now();
- memset(leds, 0, numLEDs * 3);
- basicClock(now);
- LEDS.show();
- }
- void clearLEDs()
- {
- for (int i = 0; i < numLEDs; i++) // Set all the LEDs to off
- {
- leds[i].r = 0;
- leds[i].g = 0;
- leds[i].b = 0;
- }
- }
- void basicClock(DateTime now)
- {
- unsigned char hourPos = ((now.hour()%12)*5 + (now.minute()+6)/12);
- leds[(hourPos+LEDOffset+59)%60] = CRGB::Red;
- leds[(hourPos+LEDOffset)%60] = CRGB::Red;
- leds[(hourPos+LEDOffset+1)%60] = CRGB::Red;
- leds[(now.minute()+LEDOffset)%60] = CRGB::White;
- leds[(now.second()+LEDOffset)%60] = CRGB::Blue;
- }
Advertisement
Add Comment
Please, Sign In to add comment