├── LED_SK6812MINI_PLCC4_3.2x2.8mm_5.88leads-FLIP-JSC.kicad_mod ├── README.md ├── clock-tripple.jpg ├── clock742-aug162020.ino └── sept12 ├── NTP-sketch_sept12th_anon.ino ├── README.md ├── colors_assign.ino ├── colors_assign_sin.ino ├── colors_assign_wheel.ino ├── digit_assign.ino ├── dots_assign.ino ├── matrix_assign.ino ├── matrix_assign_2.ino └── touch_inputs.ino /LED_SK6812MINI_PLCC4_3.2x2.8mm_5.88leads-FLIP-JSC.kicad_mod: -------------------------------------------------------------------------------- 1 | (footprint "LED_SK6812MINI_PLCC4_3.2x2.8mm_5.88leads-FLIP-JSC" (version 20211014) (generator pcbnew) 2 | (layer "F.Cu") 3 | (tedit 62425C00) 4 | (descr "https://cdn-shop.adafruit.com/product-files/2686/SK6812MINI_REV.01-1-2.pdf") 5 | (tags "LED RGB NeoPixel Mini") 6 | (property "Sheetfile" "digits.kicad_sch") 7 | (property "Sheetname" "Digit4 LEDs") 8 | (attr smd) 9 | (fp_text reference "D74" (at 0.254 3.01625 180) (layer "F.SilkS") 10 | (effects (font (size 1 1) (thickness 0.15))) 11 | (tstamp 8767f67b-f33e-4ae0-a8e5-736e4f34f4a4) 12 | ) 13 | (fp_text value "WS2812B" (at 0 3.25 180) (layer "F.Fab") 14 | (effects (font (size 1 1) (thickness 0.15))) 15 | (tstamp 494ec780-d764-41a4-b326-2e16a7bf5016) 16 | ) 17 | (fp_text user "${REFERENCE}" (at 0 0 180) (layer "F.Fab") 18 | (effects (font (size 0.5 0.5) (thickness 0.1))) 19 | (tstamp 86929471-3d86-4e31-99bb-cca22ff99b07) 20 | ) 21 | (fp_line (start 1.6256 -2.4511) (end 2.6416 -2.4511) (layer "F.SilkS") (width 0.12) (tstamp 0c989b9a-c07a-4c34-a6b1-3844f1effd67)) 22 | (fp_line (start -2.95 -1.651) (end 1.143 -1.651) (layer "F.SilkS") (width 0.12) (tstamp 6d846eec-efd9-4173-a668-a0936fd40014)) 23 | (fp_line (start 2.6416 -2.4511) (end 2.6416 -1.5621) (layer "F.SilkS") (width 0.12) (tstamp 909a80ce-27a0-408c-a355-38da8ffc8c69)) 24 | (fp_line (start -2.95 1.651) (end 2.794 1.651) (layer "F.SilkS") (width 0.12) (tstamp 988e54f8-e1bf-4db2-8653-b1e32cee66ea)) 25 | (fp_line (start 2.6416 -1.5621) (end 1.6256 -2.4511) (layer "F.SilkS") (width 0.12) (tstamp e3f89092-6833-4f83-8c75-154494df0f82)) 26 | (fp_rect (start -1.75 -1.5) (end 1.75 1.5) (layer "Edge.Cuts") (width 0.05) (fill none) (tstamp f7f2f321-e6e1-4f9c-b445-b625b5998a51)) 27 | (fp_line (start -3.302 -1.651) (end -3.302 1.651) (layer "F.CrtYd") (width 0.05) (tstamp 67ac3de9-74ad-4aea-a07a-2e6c07d45ebc)) 28 | (fp_line (start -3.302 1.651) (end 3.302 1.651) (layer "F.CrtYd") (width 0.05) (tstamp 69288f00-9099-44d4-8e28-8598a838b103)) 29 | (fp_line (start 3.302 -1.651) (end -3.302 -1.651) (layer "F.CrtYd") (width 0.05) (tstamp bd96de84-1ca0-4611-a971-23d45862855c)) 30 | (fp_line (start 3.302 -1.651) (end 3.302 1.651) (layer "F.CrtYd") (width 0.05) (tstamp f27a69f5-3ab4-4d9d-add0-bbd5450558cd)) 31 | (fp_line (start 1.651 -0.508) (end 0.762 -1.397) (layer "F.Fab") (width 0.1) (tstamp 17a1390e-b70f-4cb3-aa32-08bc79ec8c17)) 32 | (fp_line (start -1.651 -1.397) (end -1.651 1.397) (layer "F.Fab") (width 0.1) (tstamp 1de4fde8-0783-45d7-9261-97d0b6f6cda9)) 33 | (fp_line (start 1.651 -1.397) (end -1.651 -1.397) (layer "F.Fab") (width 0.1) (tstamp 2211b15a-e770-472e-8311-36d73bb4bebf)) 34 | (fp_line (start -1.651 1.397) (end 1.651 1.397) (layer "F.Fab") (width 0.1) (tstamp 86a72324-7939-4a50-b2ec-f7af2eb97b17)) 35 | (fp_line (start 1.651 1.397) (end 1.651 -1.397) (layer "F.Fab") (width 0.1) (tstamp 91512007-bc53-45c3-bb15-bdfe5ad4e83c)) 36 | (fp_circle (center 0 0) (end 0 -0.889) (layer "F.Fab") (width 0.1) (fill none) (tstamp 72af355a-6363-46c6-807e-c38e87635ad4)) 37 | (pad "1" smd rect (at -2.6 0.75) (size 1.58 0.85) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 7947baed-f413-490e-8eb8-65dae49f700b)) 38 | (pad "2" smd rect (at -2.6 -0.75) (size 1.58 0.85) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 33e439d6-e8da-45dc-b799-c8cc873744a3)) 39 | (pad "3" smd rect (at 2.6 -0.75) (size 1.58 0.85) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 409b254f-fff0-491f-86f6-70b6d5367c86)) 40 | (pad "4" smd rect (at 2.6 0.75) (size 1.58 0.85) (layers "F.Cu" "F.Paste" "F.Mask") (tstamp 46f1a185-a6d0-4985-add3-ea984160ae83)) 41 | (model "${KISYS3DMOD}/LED_SMD.3dshapes/LED_SK6812MINI_PLCC4_3.5x3.5mm_P1.75mm.wrl" 42 | (offset (xyz 0 0 0)) 43 | (scale (xyz 1 1 1)) 44 | (rotate (xyz 0 0 0)) 45 | ) 46 | (model "/Users/jeremycook/Desktop/TEST.step" 47 | (offset (xyz 0 0 0)) 48 | (scale (xyz 1 1 1)) 49 | (rotate (xyz 0 0 0)) 50 | ) 51 | ) 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clock 742 2 | Clock 742 is a clock made with a PCB diffuser 3 | 4 | ![image](clock-tripple.jpg) 5 | 6 | Video (single): https://www.youtube.com/watch?v=BssHpYaKQ-s 7 | Video (tripple-zone): https://www.youtube.com/watch?v=XAtKZ0VzOI4 8 | 9 | NTP code/background: https://randomnerdtutorials.com/esp32-date-time-ntp-client-server-arduino/ 10 | ESP32 touch sensor code/background: https://microcontrollerslab.com/esp32-touch-sensor-button-example/ 11 | 12 | [![Youtube](https://img.shields.io/badge/YouTube-FF0000?style=flat-square&logo=youtube&logoColor=white)](https://www.youtube.com/channel/UCrCbscxHLiaauK4H478ArRQ) [![Twitter URL](https://img.shields.io/twitter/follow/jeremyscook?style=flat-square&logo=twitter)](https://twitter.com/jeremyscook) 13 | -------------------------------------------------------------------------------- /clock-tripple.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JeremySCook/clock742/067fffd4ecac2b4cfc1118954285057d0da6134f/clock-tripple.jpg -------------------------------------------------------------------------------- /clock742-aug162020.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/esp32-date-time-ntp-client-server-arduino/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files. 7 | 8 | The above copyright notice and this permission notice shall be included in all 9 | copies or substantial portions of the Software. 10 | */ 11 | 12 | //neopixels section 13 | 14 | #include 15 | 16 | #define NUMPIXELS 85 // Number of LED controlled ==> 58 for JSC + 27 in base display 17 | #define COLOR_ORDER GRB // Define color order for your strip 18 | #define PIN 16 // Data pin for led comunication ==> will need to adjust all of this for new clock 19 | 20 | byte digits[13][14] = {{1,1,1,1,0,1,1,1,1,1,1,0,1,1}, // Digit 0 21 | {0,0,0,0,0,0,0,0,0,1,1,0,1,1}, // Digit 1 22 | {1,1,1,1,1,0,0,1,1,1,1,1,0,0}, // Digit 2 23 | {1,1,0,0,1,0,0,1,1,1,1,1,1,1}, // Digit 3 24 | {0,0,0,0,1,1,1,0,0,1,1,1,1,1}, // Digit 4 25 | {1,1,0,0,1,1,1,1,1,0,0,1,1,1}, // Digit 5 26 | {1,1,1,1,1,1,1,1,1,0,0,1,1,1}, // Digit 6 27 | {0,0,0,0,0,0,0,1,1,1,1,0,1,1}, // Digit 7 28 | {1,1,1,1,1,1,1,1,1,1,1,1,1,1}, // Digit 8 29 | {1,1,0,0,1,1,1,1,1,1,1,1,1,1}, // Digit 9 | 2D Array for numbers on 7 segment 30 | {1,1,1,1,0,1,1,1,1,1,1,0,1,1}, // Digit *0 31 | {1,1,1,1,0,1,1,1,1,0,0,0,0,0}, // Digit C (11) 32 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; // Digit blank (12) 33 | 34 | bool Dot = true; //Dot state 35 | int last_digit = 0; 36 | int cursor = 27; 37 | 38 | int digit_value = 0; // digit value to be assigned 39 | int digit_number = 0; // digit number to be assigned 40 | int hour1; 41 | int hour2; 42 | int minute1; 43 | int minute2; 44 | int minute2_now = 0; 45 | Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); 46 | 47 | //end neopixels section 48 | int digit_color[3][3] = {{0,0,50}, //blue - morning 49 | {50, 0, 50}, //purpleish - ~noon 50 | {50, 0, 0}}; //red -afternoon/night 51 | int color_red = 50; 52 | int color_blue = 50; 53 | int color_green = 50; 54 | int hour_total; 55 | 56 | // end colorshift section 57 | 58 | #include 59 | #include "time.h" 60 | 61 | const char* ssid = "your SSID"; 62 | const char* password = "your password"; 63 | 64 | const char* ntpServer = "pool.ntp.org"; 65 | const long gmtOffset_sec = -14400; 66 | const int daylightOffset_sec = 0; 67 | 68 | //touch 69 | int touch_sensor_value3 = 0; 70 | 71 | void setup(){ 72 | Serial.begin(115200); 73 | 74 | // Connect to Wi-Fi 75 | Serial.print("Connecting to "); 76 | Serial.println(ssid); 77 | WiFi.begin(ssid, password); 78 | while (WiFi.status() != WL_CONNECTED) { 79 | delay(500); 80 | Serial.print("."); 81 | } 82 | Serial.println(""); 83 | Serial.println("WiFi connected."); 84 | 85 | // Init and get the time 86 | configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); 87 | printLocalTime(); 88 | 89 | //disconnect WiFi as it's no longer needed 90 | WiFi.disconnect(true); 91 | WiFi.mode(WIFI_OFF); 92 | 93 | //neopixel setup 94 | 95 | pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 96 | pixels.clear(); // Set all pixel colors to 'off' 97 | 98 | // will need a time to array 99 | // will need routine to get time intermittently via WiFi 100 | // dots @ 55, 56 - digits start @ 27, 41, 57, 71 101 | //end neopixel setup 102 | 103 | randomSeed(analogRead(0)); 104 | 105 | } 106 | 107 | void loop(){ 108 | //delay(100); 109 | touch_sensor_value3 = touchRead(T3); //PIN3 110 | printLocalTime(); 111 | 112 | pixels.clear(); 113 | colors_assign(); 114 | //dots_assign(); 115 | digit_number = 0; 116 | digit_value = hour1; 117 | if (digit_value == 0) digit_value = 12; 118 | digit_assign(); 119 | digit_number = 1; 120 | digit_value = hour2; 121 | digit_assign(); 122 | digit_number = 2; 123 | digit_value = minute1; 124 | digit_assign(); 125 | digit_number = 3; 126 | digit_value = minute2; 127 | digit_assign(); 128 | matrix_assign(); 129 | pixels.show(); 130 | } 131 | 132 | 133 | 134 | void printLocalTime(){ 135 | struct tm timeinfo; 136 | if(!getLocalTime(&timeinfo)){ 137 | Serial.println("Failed to obtain time"); 138 | return; 139 | } 140 | Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S"); 141 | Serial.print("Day of week: "); 142 | Serial.println(&timeinfo, "%A"); 143 | Serial.print("Month: "); 144 | Serial.println(&timeinfo, "%B"); 145 | Serial.print("Day of Month: "); 146 | Serial.println(&timeinfo, "%d"); 147 | Serial.print("Year: "); 148 | Serial.println(&timeinfo, "%Y"); 149 | Serial.print("Hour: "); 150 | Serial.println(&timeinfo, "%H"); 151 | Serial.print("Hour (12 hour format): "); 152 | Serial.println(&timeinfo, "%I"); 153 | Serial.print("Minute: "); 154 | Serial.println(&timeinfo, "%M"); 155 | Serial.print("Second: "); 156 | Serial.println(&timeinfo, "%S"); 157 | Serial.print("Hour 2: "); 158 | hour2 = timeinfo.tm_hour %10; 159 | Serial.println(hour2); 160 | Serial.print("Hour 1: "); 161 | hour1 = timeinfo.tm_hour /10; 162 | Serial.println(hour1); 163 | Serial.print("Minute 2: "); 164 | minute2 = timeinfo.tm_min %10; 165 | Serial.println(minute2); 166 | Serial.print("Minute 1: "); 167 | minute1 = timeinfo.tm_min /10; 168 | Serial.println(minute1); 169 | hour_total = timeinfo.tm_hour; 170 | } 171 | 172 | /*void dots_assign(){ 173 | //dots 174 | //leds[55] = CRGB::Green; 175 | //leds[56] = CRGB::Green; 176 | pixels.setPixelColor(55, pixels.Color(color_red, color_green, color_blue)); 177 | pixels.setPixelColor(56, pixels.Color(color_red, color_green, color_blue)); 178 | //end dots 179 | }*/ 180 | 181 | void digit_assign(){ 182 | //pixels.clear(); // Set all pixel colors to 'off' 183 | if (digit_number==0){ 184 | cursor = 27; 185 | for(int k=0; k<=13;k++){ 186 | // Serial.print(digits[digit][k]); 187 | if (digits[digit_value][k]== 1){pixels.setPixelColor(cursor, pixels.Color(color_red, color_green, color_blue));} 188 | else if (digits[digit_value][k]==0){pixels.setPixelColor(cursor, pixels.Color(0, 0, 0));}; 189 | cursor ++; 190 | } 191 | } 192 | if (digit_number==1){ 193 | cursor = 41; 194 | for(int k=0; k<=13;k++){ 195 | // Serial.print(digits[digit][k]); 196 | if (digits[digit_value][k]== 1){pixels.setPixelColor(cursor, pixels.Color(color_red, color_green, color_blue));} 197 | else if (digits[digit_value][k]==0){pixels.setPixelColor(cursor, pixels.Color(0, 0, 0));}; 198 | cursor ++; 199 | } 200 | } 201 | if (digit_number==2){ 202 | cursor = 57; 203 | for(int k=0; k<=13;k++){ 204 | // Serial.print(digits[digit][k]); 205 | if (digits[digit_value][k]== 1){pixels.setPixelColor(cursor, pixels.Color(color_red, color_green, color_blue));} 206 | else if (digits[digit_value][k]==0){pixels.setPixelColor(cursor, pixels.Color(0, 0, 0));}; 207 | cursor ++; 208 | } 209 | } 210 | if (digit_number==3){ 211 | cursor = 71; 212 | for(int k=0; k<=13;k++){ 213 | // Serial.print(digits[digit][k]); 214 | if (digits[digit_value][k]== 1){pixels.setPixelColor(cursor, pixels.Color(color_red, color_green, color_blue));} 215 | else if (digits[digit_value][k]==0){pixels.setPixelColor(cursor, pixels.Color(0, 0, 0));}; 216 | cursor ++; 217 | } 218 | } 219 | } 220 | 221 | void matrix_assign(){ 222 | 223 | //colon 224 | //if (minute2 != minute2_now) {//changes matrix only when minute advances 225 | //pixels.clear(); 226 | cursor = 0; 227 | for(int k=0; k<=26;k++){ 228 | // Serial.print(digits[digit][k]); 229 | int randNumber = random(20); 230 | int randNumber1 = random(27); 231 | int randNumber2 = random(54); 232 | pixels.setPixelColor(cursor, pixels.Color((color_red*randNumber/10), (color_green*randNumber/10), (color_blue*randNumber/10))); 233 | if (randNumber1 == k){ //random pixels (1/27) 234 | pixels.setPixelColor(cursor, pixels.Color((color_blue*randNumber/10), (color_red*randNumber/10), (color_green*randNumber/10))); 235 | } 236 | if (randNumber2 == k){ //random pixels (1/54) 237 | pixels.setPixelColor(cursor, pixels.Color((color_green*randNumber/10), (color_blue*randNumber/10), (color_red*randNumber/10))); 238 | } 239 | cursor ++; 240 | } 241 | //colon 242 | pixels.setPixelColor(55, pixels.Color(color_red, color_green, color_blue)); 243 | pixels.setPixelColor(56, pixels.Color(color_red, color_green, color_blue)); 244 | pixels.show(); 245 | delay(500); 246 | pixels.setPixelColor(55, pixels.Color(0, 0, 0)); 247 | pixels.setPixelColor(56, pixels.Color(0, 0, 0)); 248 | pixels.show(); 249 | delay(500); //need to change this to pick up on seconds later and coordinate with colon 250 | // minute2_now = minute2; 251 | } 252 | //} 253 | 254 | 255 | void colors_assign(){ 256 | Serial.print("touch_sensor_value3 = "); 257 | Serial.println(touch_sensor_value3); 258 | 259 | //color_red = map(hour_total, 0, 23, 0, 50); 260 | //if (hour_total < 12) color_green = map((hour_total -11), 0, 12, 0, 30); 261 | //if (hour_total >= 12) color_green = map((23 - hour_total), 0, 12, 0, 30); 262 | //color_blue = map(abs(24 - hour_total), 0, 23, 0, 50); 263 | 264 | if (hour_total < 12){ 265 | color_red = digit_color[0][0]; 266 | color_green = digit_color[0][1]; 267 | color_blue = digit_color[0][2]; 268 | } 269 | if (hour_total == 12){ 270 | color_red = digit_color[1][0]; 271 | color_green = digit_color[1][1]; 272 | color_blue = digit_color[1][2]; 273 | } 274 | if (hour_total > 12){ 275 | color_red = digit_color[2][0]; 276 | color_green = digit_color[2][1]; 277 | color_blue = digit_color[2][2]; 278 | } 279 | 280 | if (touch_sensor_value3 > 18000){ 281 | color_red = 75; 282 | color_green = 75; 283 | color_blue = 25; 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /sept12/NTP-sketch_sept12th_anon.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Rui Santos 3 | Complete project details at https://RandomNerdTutorials.com/esp32-date-time-ntp-client-server-arduino/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files. 7 | 8 | The above copyright notice and this permission notice shall be included in all 9 | copies or substantial portions of the Software. 10 | */ 11 | 12 | //neopixels section 13 | 14 | #include 15 | 16 | #define NUMPIXELS 255 // Number of LED controlled ==> 85 * number of faces 17 | #define COLOR_ORDER GRB // Define color order for your strip 18 | #define PIN 16 // Data pin for led comunication ==> will need to adjust all of this for new clock 19 | 20 | byte digits[13][14] = {{1,1,1,1,0,1,1,1,1,1,1,0,1,1}, // Digit 0 21 | {0,0,0,0,0,0,0,0,0,1,1,0,1,1}, // Digit 1 22 | {1,1,1,1,1,0,0,1,1,1,1,1,0,0}, // Digit 2 23 | {1,1,0,0,1,0,0,1,1,1,1,1,1,1}, // Digit 3 24 | {0,0,0,0,1,1,1,0,0,1,1,1,1,1}, // Digit 4 25 | {1,1,0,0,1,1,1,1,1,0,0,1,1,1}, // Digit 5 26 | {1,1,1,1,1,1,1,1,1,0,0,1,1,1}, // Digit 6 27 | {0,0,0,0,0,0,0,1,1,1,1,0,1,1}, // Digit 7 28 | {1,1,1,1,1,1,1,1,1,1,1,1,1,1}, // Digit 8 29 | {1,1,0,0,1,1,1,1,1,1,1,1,1,1}, // Digit 9 | 2D Array for numbers on 7 segment 30 | {1,1,1,1,0,1,1,1,1,1,1,0,1,1}, // Digit *0 31 | {1,1,1,1,0,1,1,1,1,0,0,0,0,0}, // Digit C (11) 32 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; // Digit blank (12) 33 | 34 | bool Dot = true; //Dot state 35 | int last_digit = 0; 36 | int cursor; 37 | int cursor1; 38 | 39 | int digit_value = 0; // digit value to be assigned 40 | int digit_number = 0; // digit number to be assigned 41 | int hour1; 42 | int hour2; 43 | int minute1; 44 | int minute2; 45 | int minute2_now = 0; 46 | int faceID; 47 | 48 | Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); 49 | 50 | //end neopixels section 51 | int digit_color[3][3] = {{0,0,10}, //blue - morning 52 | {10, 0, 10}, //purpleish - ~noon 53 | {10, 0, 0}}; //red -afternoon/night 54 | int color_red = 50; 55 | int color_blue = 50; 56 | int color_green = 50; 57 | int color_scale = 5; //scales brightness between 1-5 based on touch inputs 58 | float color_intensity = 1; //scales brightness based on time of day 59 | 60 | int hour_total; 61 | int minute_total; 62 | int minutes_day; //minutes into day 63 | int minutes_day_now = 0; //minutes into day set 64 | int minutes_map; 65 | 66 | // end colorshift section 67 | 68 | #include 69 | #include "time.h" 70 | 71 | const char* ssid = "INPUT YOUR SSID HERE"; 72 | const char* password = "INPUT YOUR PASSWORD HERE"; 73 | 74 | const char* ntpServer = "pool.ntp.org"; 75 | long gmtOffset_sec = -14400; //modify for each face 76 | const int daylightOffset_sec = 0; 77 | 78 | //touch 79 | int touch_sensor_value3 = 0; 80 | int touch_sensor_value5 = 0; 81 | int touch_sensor_value7 = 0; 82 | int touch_sensor_value9 = 0; 83 | 84 | void setup(){ 85 | Serial.begin(115200); 86 | 87 | // Connect to Wi-Fi 88 | Serial.print("Connecting to "); 89 | Serial.println(ssid); 90 | WiFi.begin(ssid, password); 91 | while (WiFi.status() != WL_CONNECTED) { 92 | delay(500); 93 | Serial.print("."); 94 | } 95 | Serial.println(""); 96 | Serial.println("WiFi connected."); 97 | 98 | // Init and get the time 99 | configTime(-14400, daylightOffset_sec, ntpServer); //Does this log on each time and reset time??? Neet to find more efficient way 100 | printLocalTime(); 101 | 102 | //disconnect WiFi as it's no longer needed 103 | WiFi.disconnect(true); 104 | WiFi.mode(WIFI_OFF); 105 | 106 | //neopixel setup 107 | 108 | pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 109 | pixels.setBrightness(20); 110 | pixels.clear(); // Set all pixel colors to 'off' 111 | 112 | // will need a time to array 113 | // will need routine to get time intermittently via WiFi 114 | // dots @ 55, 56 - digits start @ 27, 41, 57, 71 115 | //end neopixel setup 116 | 117 | randomSeed(analogRead(0)); 118 | 119 | } 120 | 121 | void loop(){ 122 | //pixels.clear(); 123 | touch_inputs(); 124 | printLocalTime(); 125 | if (minutes_day != minutes_day_now){ 126 | face2(); 127 | face1(); 128 | face0(); 129 | minutes_day_now = minutes_day; 130 | } 131 | } 132 | 133 | void face0(){ 134 | faceID = 0; 135 | configTime(28800, daylightOffset_sec, ntpServer); // +8 hour offset - China 136 | 137 | printLocalTime(); 138 | colors_assign(); 139 | digit_number = 0; 140 | digit_value = hour1; 141 | if (digit_value == 0) digit_value = 12; 142 | digit_assign(); 143 | digit_number = 1; 144 | digit_value = hour2; 145 | digit_assign(); 146 | dots_assign(); 147 | digit_number = 2; 148 | digit_value = minute1; 149 | digit_assign(); 150 | digit_number = 3; 151 | digit_value = minute2; 152 | digit_assign(); 153 | matrix_assign_2(); 154 | } 155 | 156 | void face1(){ 157 | faceID = 1; 158 | configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); //home face - east coast USA 159 | 160 | printLocalTime(); 161 | colors_assign(); 162 | digit_number = 0; 163 | digit_value = hour1; 164 | if (digit_value == 0) digit_value = 12; 165 | digit_assign(); 166 | digit_number = 1; 167 | digit_value = hour2; 168 | digit_assign(); 169 | dots_assign(); 170 | digit_number = 2; 171 | digit_value = minute1; 172 | digit_assign(); 173 | digit_number = 3; 174 | digit_value = minute2; 175 | digit_assign(); 176 | matrix_assign(); 177 | } 178 | 179 | void face2(){ 180 | faceID = 2; 181 | configTime(-25200, daylightOffset_sec, ntpServer); // -7 hour offset - West Coast USA 182 | 183 | printLocalTime(); 184 | colors_assign(); 185 | dots_assign(); 186 | digit_number = 0; 187 | digit_value = hour1; 188 | if (digit_value == 0) digit_value = 12; 189 | digit_assign(); 190 | digit_number = 1; 191 | digit_value = hour2; 192 | digit_assign(); 193 | dots_assign(); 194 | digit_number = 2; 195 | digit_value = minute1; 196 | digit_assign(); 197 | digit_number = 3; 198 | digit_value = minute2; 199 | digit_assign(); 200 | matrix_assign_2(); 201 | } 202 | 203 | void printLocalTime(){ 204 | struct tm timeinfo; 205 | if(!getLocalTime(&timeinfo)){ 206 | Serial.println("Failed to obtain time"); 207 | return; 208 | } 209 | hour2 = timeinfo.tm_hour %10; 210 | hour1 = timeinfo.tm_hour /10; 211 | minute2 = timeinfo.tm_min %10; 212 | minute1 = timeinfo.tm_min /10; 213 | hour_total = timeinfo.tm_hour; 214 | minute_total = timeinfo.tm_min; 215 | minutes_day = timeinfo.tm_hour*60 + timeinfo.tm_min; 216 | minutes_map = map(minutes_day, 0, 1440, 0, 255); 217 | } 218 | 219 | /*void dots_assign(){ 220 | //dots 221 | //leds[55] = CRGB::Green; 222 | //leds[56] = CRGB::Green; 223 | pixels.setPixelColor(55, pixels.Color(color_red, color_green, color_blue)); 224 | pixels.setPixelColor(56, pixels.Color(color_red, color_green, color_blue)); 225 | //end dots 226 | }*/ 227 | -------------------------------------------------------------------------------- /sept12/README.md: -------------------------------------------------------------------------------- 1 | Clock code as of September 12th 2022. Code is working with three faces, split up into different filee. 2 | Still quite rough and in need of improvement, but functional. 3 | 4 | All files must be in same folder named "NTP-sketch_sept12_anon" 5 | 6 | anon as in my SSID/password is taken out. 7 | -------------------------------------------------------------------------------- /sept12/colors_assign.ino: -------------------------------------------------------------------------------- 1 | #if 0 2 | void colors_assign(){ 3 | Serial.print("touch_sensor_value3 = "); 4 | Serial.println(touch_sensor_value3); 5 | 6 | //color_red = map(hour_total, 0, 23, 0, 50); 7 | //if (hour_total < 12) color_green = map((hour_total -11), 0, 12, 0, 30); 8 | //if (hour_total >= 12) color_green = map((23 - hour_total), 0, 12, 0, 30); 9 | //color_blue = map(abs(24 - hour_total), 0, 23, 0, 50); 10 | 11 | if (hour_total < 12){ 12 | color_red = digit_color[0][0]*color_scale; 13 | color_green = digit_color[0][1]*color_scale; 14 | color_blue = digit_color[0][2]*color_scale; 15 | } 16 | if (hour_total == 12){ 17 | color_red = digit_color[1][0]*color_scale; 18 | color_green = digit_color[1][1]*color_scale; 19 | color_blue = digit_color[1][2]*color_scale; 20 | } 21 | if (hour_total > 12){ 22 | color_red = digit_color[2][0]*color_scale; 23 | color_green = digit_color[2][1]*color_scale; 24 | color_blue = digit_color[2][2]*color_scale; 25 | } 26 | 27 | if (touch_sensor_value3 > 30000){ 28 | color_red = 75; 29 | color_green = 0; 30 | color_blue = 0; 31 | } 32 | if (touch_sensor_value9 > 30000){ 33 | color_red = 0; 34 | color_green = 75; 35 | color_blue = 0; 36 | } 37 | if ((touch_sensor_value5 > 30000) && (color_scale < 5)){ //turn up color 38 | color_scale++; 39 | } 40 | if ((touch_sensor_value7 > 30000) && (color_scale > 1)){ //turn down color 41 | color_scale--; 42 | } 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /sept12/colors_assign_sin.ino: -------------------------------------------------------------------------------- 1 | 2 | void colors_assign(){ 3 | 4 | float color_intensity_sin = 2 + sin(((((hour_total*60+minute_total)*360)/1440)-90)*3.14/180); 5 | color_intensity = color_intensity_sin; 6 | float color_red_sin = 1 + sin(((((hour_total*60+minute_total)*360)/1440)-270)*3.14/180); 7 | color_red = color_red_sin*color_scale*color_intensity*4; 8 | float color_blue_sin = 1 + sin(((((hour_total*60+minute_total)*360)/1440)-90)*3.14/180); 9 | color_blue = color_blue_sin*color_scale*color_intensity*4; 10 | float color_green_sin = 1 + sin(((((hour_total*60+minute_total)*360)/1440)+225)*3.14/180); 11 | color_green = color_green_sin*color_scale*color_intensity*0; 12 | 13 | Serial.print("face = "); Serial.println(faceID); 14 | Serial.print("minutes_map "); 15 | Serial.println(minutes_map); 16 | 17 | if (touch_sensor_value3 > 30000){ 18 | color_red = 75; 19 | color_green = 0; 20 | color_blue = 0; 21 | } 22 | if (touch_sensor_value9 > 30000){ 23 | color_red = 0; 24 | color_green = 75; 25 | color_blue = 0; 26 | } 27 | if ((touch_sensor_value5 > 30000) && (color_scale < 5)){ //turn up color 28 | color_scale++; 29 | } 30 | if ((touch_sensor_value7 > 30000) && (color_scale > 1)){ //turn down color 31 | color_scale--; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sept12/colors_assign_wheel.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | uint32_t Wheel(byte WheelPos) { 4 | WheelPos = 255 - WheelPos; 5 | if(WheelPos < 85) { 6 | return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3); 7 | } 8 | if(WheelPos < 170) { 9 | WheelPos -= 85; 10 | return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3); 11 | } 12 | WheelPos -= 170; 13 | return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 14 | } 15 | -------------------------------------------------------------------------------- /sept12/digit_assign.ino: -------------------------------------------------------------------------------- 1 | void digit_assign(){ 2 | int delay_between_numbers = 50; 3 | 4 | if (digit_number==0){ 5 | 6 | for(int scroll_value = 0; scroll_value<=digit_value; scroll_value++){ 7 | 8 | cursor = 27 + faceID*85; 9 | cursor1 = cursor; 10 | 11 | for(int k=0; k<=13;k++){ //clear digit 12 | pixels.setPixelColor(cursor1, pixels.Color(0, 0, 0)); 13 | cursor1 ++; 14 | } 15 | pixels.show(); 16 | 17 | if (hour1 != 0){ //keeps from scrolling on blank preceeding digit 18 | delay(delay_between_numbers); 19 | for(int k=0; k<=13;k++){ 20 | //Serial.print("cursor "); Serial.println(cursor); 21 | // Serial.print(digits[digit][k]); 22 | if (digits[scroll_value][k]== 1){pixels.setPixelColor(cursor, Wheel(minutes_map));} 23 | else if (digits[scroll_value][k]==0){pixels.setPixelColor(cursor, pixels.Color(0, 0, 0));}; 24 | cursor ++; 25 | } 26 | pixels.show(); 27 | //delay(5); 28 | } 29 | } 30 | } 31 | 32 | 33 | if (digit_number==1){ 34 | 35 | for(int scroll_value = 0; scroll_value<=digit_value; scroll_value++){ 36 | 37 | cursor = 41 + faceID*85; 38 | cursor1 = cursor; 39 | 40 | for(int k=0; k<=13;k++){ //clear digit 41 | pixels.setPixelColor(cursor1, pixels.Color(0, 0, 0)); 42 | cursor1 ++; 43 | } 44 | pixels.show(); 45 | delay(delay_between_numbers); 46 | for(int k=0; k<=13;k++){ 47 | // Serial.print(digits[digit][k]); 48 | if (digits[scroll_value][k]== 1){pixels.setPixelColor(cursor, Wheel(minutes_map));} 49 | else if (digits[scroll_value][k]==0){pixels.setPixelColor(cursor, pixels.Color(0, 0, 0));}; 50 | cursor ++; 51 | } 52 | pixels.show(); 53 | //delay(50); 54 | } 55 | } 56 | 57 | if (digit_number==2){ 58 | 59 | for(int scroll_value = 0; scroll_value<=digit_value; scroll_value++){ 60 | 61 | cursor = 57 + faceID*85; 62 | cursor1 = cursor; 63 | 64 | for(int k=0; k<=13;k++){ //clear digit 65 | pixels.setPixelColor(cursor1, pixels.Color(0, 0, 0)); 66 | cursor1 ++; 67 | } 68 | pixels.show(); 69 | delay(delay_between_numbers); 70 | for(int k=0; k<=13;k++){ 71 | // Serial.print(digits[digit][k]); 72 | if (digits[scroll_value][k]== 1){pixels.setPixelColor(cursor, Wheel(minutes_map));} 73 | else if (digits[scroll_value][k]==0){pixels.setPixelColor(cursor, pixels.Color(0, 0, 0));}; 74 | cursor ++; 75 | } 76 | pixels.show(); 77 | //delay(50); 78 | } 79 | } 80 | 81 | if (digit_number==3){ 82 | 83 | for(int scroll_value = 0; scroll_value<=digit_value; scroll_value++){ 84 | 85 | cursor = 71 + faceID*85; 86 | cursor1 = cursor; 87 | 88 | for(int k=0; k<=13;k++){ //clear digit 89 | pixels.setPixelColor(cursor1, pixels.Color(0, 0, 0)); 90 | cursor1 ++; 91 | } 92 | pixels.show(); 93 | delay(delay_between_numbers); 94 | for(int k=0; k<=13;k++){ 95 | // Serial.print(digits[digit][k]); 96 | if (digits[scroll_value][k]== 1){pixels.setPixelColor(cursor, Wheel(minutes_map));} 97 | else if (digits[scroll_value][k]==0){pixels.setPixelColor(cursor, pixels.Color(0, 0, 0));}; 98 | cursor ++; 99 | } 100 | pixels.show(); 101 | //delay(50); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /sept12/dots_assign.ino: -------------------------------------------------------------------------------- 1 | void dots_assign(){ 2 | pixels.setPixelColor(55 + faceID*85, pixels.Color(0, 0, 0)); 3 | pixels.setPixelColor(56 + faceID*85, pixels.Color(0, 0, 0)); 4 | pixels.show(); 5 | delay(20); 6 | pixels.setPixelColor((55 + faceID*85), Wheel(minutes_map)); 7 | pixels.setPixelColor((56 + faceID*85), Wheel(minutes_map)); 8 | pixels.show(); 9 | //delay(50); 10 | } 11 | -------------------------------------------------------------------------------- /sept12/matrix_assign.ino: -------------------------------------------------------------------------------- 1 | void matrix_assign(){ 2 | 3 | //colon 4 | //if (minute2 != minute2_now) {//changes matrix only when minute advances 5 | //pixels.clear(); 6 | cursor = 0 + faceID*85; 7 | for(int k=0; k<=26;k++){ 8 | // Serial.print(digits[digit][k]); 9 | int randNumber = random(2); 10 | int randNumber1 = random(27); 11 | int randNumber2 = random(54); 12 | pixels.setPixelColor(cursor, Wheel(minutes_map)); 13 | if (randNumber == 1){ //random pixels (1/2) 14 | pixels.setPixelColor(cursor, 0); 15 | pixels. 16 | } 17 | if (randNumber1 == k){ //random pixels (1/27) 18 | pixels.setPixelColor(cursor, Wheel(minutes_map-25)); 19 | } 20 | if (randNumber2 == k){ //random pixels (1/54) 21 | pixels.setPixelColor(cursor, Wheel(minutes_map-75)); 22 | } 23 | cursor ++; 24 | } 25 | pixels.show(); 26 | } 27 | -------------------------------------------------------------------------------- /sept12/matrix_assign_2.ino: -------------------------------------------------------------------------------- 1 | void matrix_assign_2(){ 2 | 3 | //colon 4 | //if (minute2 != minute2_now) {//changes matrix only when minute advances 5 | //pixels.clear(); 6 | cursor = 0 + faceID*85; 7 | for(int k=0; k<=26;k++){ 8 | 9 | int randNumber = random(2); 10 | int randNumber1 = random(27); 11 | int randNumber2 = random(54); 12 | 13 | if (randNumber == 1){ //random pixels (1/2) 14 | pixels.setPixelColor(cursor, 0); 15 | } 16 | if (randNumber1 == k){ //random pixels (1/27) 17 | pixels.setPixelColor(cursor, Wheel(minutes_map-25)); 18 | } 19 | if (randNumber2 == k){ //random pixels (1/54) 20 | pixels.setPixelColor(cursor, Wheel(minutes_map-75)); 21 | } 22 | cursor ++; 23 | } 24 | pixels.show(); 25 | } 26 | -------------------------------------------------------------------------------- /sept12/touch_inputs.ino: -------------------------------------------------------------------------------- 1 | void touch_inputs(){ 2 | touch_sensor_value3 = touchRead(T3); //PIN3 - UPPER-LEFT 3 | touch_sensor_value5 = touchRead(T5); //UPPER-RIGHT 4 | touch_sensor_value7 = touchRead(T7); //LOWER-RIGHT 5 | touch_sensor_value9 = touchRead(T9); //LOWER-LEFT 6 | 7 | /* if(touch_sensor_value3 = HIGH){ 8 | faceID == 1; 9 | matrix_assign_2(); 10 | } 11 | */ 12 | } 13 | --------------------------------------------------------------------------------