#include #include "RTClib.h" #include #include #ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket #endif RTC_DS3231 rtc; #define CLK 5 #define DIO 4 int touchClock = 7; int touchClockVal = 0; TM1637Display display(CLK, DIO); int a, t; #define BUTTON_PIN 8 #define PIXEL_PIN 6 #define PIXEL_COUNT 3 Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800); boolean oldState = HIGH; int mode = 0; // Currently-active animation mode, 0-9 void setup () { Wire.begin(); display.setBrightness(0); pinMode(BUTTON_PIN, INPUT); strip.begin(); strip.show(); } void loop (){ uint8_t segto; int value = 1244; segto = 0x80|display.encodeDigit((value/100)%10); display.setSegments(&segto,1,1); DateTime now = rtc.now(); a=now.second()%2; t = (now.hour()* 100 )+ now.minute(); display.showNumberDec(t, true); if (digitalRead (7) == 1){ touchClockVal++; if (touchClockVal>=3) { touchClockVal=1; } delay (500); } if (touchClockVal==1) { display.setBrightness(7); } if (touchClockVal==2) { display.setBrightness(0); } boolean newState = digitalRead(BUTTON_PIN); if((newState == LOW) && (oldState == HIGH)) { delay(20); newState = digitalRead(BUTTON_PIN); if(newState == LOW) { if(++mode > 8) mode = 0; switch(mode) { case 0: colorWipe(strip.Color( 0, 0, 0), 50); break; case 1: colorWipe(strip.Color(255, 0, 0), 50); break; case 2: colorWipe(strip.Color( 0, 255, 0), 50); break; case 3: colorWipe(strip.Color( 0, 0, 255), 50); break; case 4: theaterChase(strip.Color(127, 127, 127), 50); break; case 5: theaterChase(strip.Color(127, 0, 0), 50); break; case 6: theaterChase(strip.Color( 0, 0, 127), 50); break; case 7: rainbow(10); break; case 8: theaterChaseRainbow(50); break; } } } oldState = newState; } void colorWipe(uint32_t color, int wait) { for(int i=0; i