Components and supplies
Arduino Nano R3
Breadboard (generic)
Jumper wires (generic)
Card stock, glue, misc supplies
Real Time Clock (RTC)
2812b addressable rgb Leds
Tools and machines
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
wordclock2812.ino
arduino
1#include <Wire.h> 2#include "RTClib.h" 3#include <FastLED.h> 4#define NUM_LEDS 22 5#define DATA_PIN 7 6CRGB leds[NUM_LEDS]; 7 8RTC_DS1307 rtc; 9 10 11void setup () { 12 13 14 15 Serial.begin(9600); 16 if (! rtc.begin()) { 17 Serial.println("Couldn't find RTC"); 18 while (1); 19 } 20 21 if (! rtc.isrunning()) { 22 Serial.println("RTC is NOT running!"); 23 24 rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); 25 26 } 27 28{ 29 30FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS); 31} 32 33} 34void loop () { 35 DateTime now = rtc.now(); 36 int h; 37 38 Serial.print(now.hour(), DEC); 39 h=(now.hour()); 40 if (now.minute()>34){ 41 h=h+1; 42 } 43 44 45 Serial.print(':'); 46 Serial.print(now.minute(), DEC); 47 leds[0] = CRGB::Yellow; 48 leds[20] = CRGB::Yellow; 49 FastLED.show(); 50 if (now.minute() <=4){ 51 Serial.print ("nothing"); 52 53 leds[1] = CRGB::Black; 54 leds[2] = CRGB::Black; 55 leds[3] = CRGB::Black; 56 leds[4] = CRGB::Black; 57 leds[5] = CRGB::Black; 58 leds[6] = CRGB::Black; 59 leds[7] = CRGB::Black; 60 61 FastLED.show(); 62 } 63 else if (now.minute() <=9){ 64 Serial.print ("five minutes past"); 65 leds[5] = CRGB::Red; 66 leds[6] = CRGB::Red; 67 leds[10] = CRGB::Red; 68 FastLED.show(); 69 } 70 else if (now.minute() <=14){ 71 Serial.print ("ten minutes past"); 72 leds[5] = CRGB::Black; 73 leds[2] = CRGB::Red; 74 leds[6] = CRGB::Red; 75 leds[10] = CRGB::Red; 76 FastLED.show(); 77 } 78 else if (now.minute() <=19){ 79 Serial.print ("quarter past"); 80 leds[2] = CRGB::Black; 81 leds[4] = CRGB::Red; 82 leds[6] = CRGB::Black; 83 leds[10] = CRGB::Red; 84 FastLED.show(); 85 } 86 else if (now.minute() <=24){ 87 Serial.print ("twenty minutes past"); 88 leds[4] = CRGB::Black; 89 leds[3] = CRGB::Red; 90 leds[6] = CRGB::Red; 91 leds[10] = CRGB::Red; 92 FastLED.show(); 93 } 94 else if (now.minute() <=29){ 95 Serial.print ("twenty-five minutes past"); 96 97 leds[3] = CRGB::Red; 98 leds[5] = CRGB::Red; 99 leds[6] = CRGB::Red; 100 leds[10] = CRGB::Red; 101 FastLED.show(); 102 103 104 } 105 else if (now.minute() <=34){ 106 Serial.print ("half past"); 107 leds[3] = CRGB::Black; 108 leds[5] = CRGB::Black; 109 leds[1] = CRGB::Red; 110 leds[6] = CRGB::Black; 111 leds[10] = CRGB::Red; 112 FastLED.show(); 113 114 115 } 116 else if (now.minute() <=39){ 117 Serial.print ("twenty-five minutes to"); 118 leds[1] = CRGB::Black; 119 leds[10] = CRGB::Black; 120 leds[3] = CRGB::Red; 121 leds[5] = CRGB::Red; 122 leds[6] = CRGB::Red; 123 leds[7] = CRGB::Red; 124 FastLED.show(); 125 126 } 127 else if (now.minute() <=44){ 128 Serial.print ("twenty minutes to"); 129 leds[4] = CRGB::Black; 130 leds[5] = CRGB::Black; 131 leds[3] = CRGB::Red; 132 leds[6] = CRGB::Red; 133 leds[7] = CRGB::Red; 134 FastLED.show(); 135 } 136 else if (now.minute() <=49){ 137 Serial.print ("quarter to"); 138 leds[3] = CRGB::Black; 139 leds[4] = CRGB::Red; 140 leds[6] = CRGB::Black; 141 leds[7] = CRGB::Red; 142 FastLED.show(); 143 144 } 145 else if (now.minute() <=54){ 146 Serial.print ("ten minutes to"); 147 leds[4] = CRGB::Black; 148 leds[2] = CRGB::Red; 149 leds[6] = CRGB::Red; 150 leds[7] = CRGB::Red; 151 FastLED.show(); 152 153 154 } 155 else if (now.minute() <=59){ 156 Serial.print ("five minutes to"); 157 leds[2] = CRGB::Black; 158 leds[5] = CRGB::Red; 159 leds[6] = CRGB::Red; 160 leds[7] = CRGB::Red; 161 FastLED.show(); 162 } 163 164 165 166 if (h==1){ 167 leds[21] = CRGB::Black; 168 leds[9] = CRGB::Blue; 169 FastLED.show(); 170 } 171 if (h==2){ 172 leds[9] = CRGB::Black; 173 leds[11] = CRGB::Blue; 174 FastLED.show(); 175 } 176 if (h==3){ 177 leds[11] = CRGB::Black; 178 leds[8] = CRGB::Blue; 179 FastLED.show(); 180 } 181 if (h==4){ 182 leds[8] = CRGB::Black; 183 leds[12] = CRGB::Red; 184 FastLED.show(); 185 } 186 if (h==5){ 187 leds[12] = CRGB::Black; 188 leds[13] = CRGB::Red; 189 FastLED.show(); 190 } 191 if (h==6){ 192 leds[13] = CRGB::Black; 193 leds[16] = CRGB::Red; 194 FastLED.show(); 195 } 196 if (h==7){ 197 leds[16] = CRGB::Black; 198 leds[15] = CRGB::Blue; 199 FastLED.show(); 200 } 201 if (h==8){ 202 leds[15] = CRGB::Black; 203 leds[14] = CRGB::Blue; 204 FastLED.show(); 205 } 206 if (h==9){ 207 leds[14] = CRGB::Black; 208 leds[17] = CRGB::Blue; 209 FastLED.show(); 210 } 211 if (h==10){ 212 leds[17] = CRGB::Black; 213 leds[18] = CRGB::Blue; 214 FastLED.show(); 215 } 216 if (h==11){ 217 leds[18] = CRGB::Black; 218 leds[19] = CRGB::Blue; 219 FastLED.show(); 220 } 221 if (h==12){ 222 leds[19] = CRGB::Black; 223 leds[21] = CRGB::Green; 224 FastLED.show(); 225 } 226 227 if (h==13){ 228 leds[21] = CRGB::Black; 229 leds[9] = CRGB::Green; 230 FastLED.show(); 231 } 232 if (h==14){ 233 leds[9] = CRGB::Black; 234 leds[11] = CRGB::Green; 235 FastLED.show(); 236 } 237 if (h==15){ 238 leds[11] = CRGB::Black; 239 leds[8] = CRGB::Green; 240 FastLED.show(); 241 } 242 if (h==16){ 243 leds[8] = CRGB::Black; 244 leds[12] = CRGB::Green; 245 FastLED.show(); 246 } 247 if (h==17){ 248 leds[12] = CRGB::Black; 249 leds[13] = CRGB::Green; 250 FastLED.show(); 251 } 252 if (h==18){ 253 leds[13] = CRGB::Black; 254 leds[16] = CRGB::Green; 255 FastLED.show(); 256 } 257 if (h==19){ 258 leds[16] = CRGB::Black; 259 leds[15] = CRGB::Green; 260 FastLED.show(); 261 } 262 if (h==20){ 263 leds[15] = CRGB::Black; 264 leds[14] = CRGB::Green; 265 FastLED.show(); 266 } 267 if (h==21){ 268 leds[14] = CRGB::Black; 269 leds[17] = CRGB::Green; 270 FastLED.show(); 271 } 272 if (h==22){ 273 leds[17] = CRGB::Black; 274 leds[18] = CRGB::Green; 275 FastLED.show(); 276 } 277 if (h==23){ 278 leds[18] = CRGB::Black; 279 leds[19] = CRGB::Green; 280 FastLED.show(); 281 } 282 if (h==0){ 283 leds[19] = CRGB::Black; 284 leds[21] = CRGB::Red; 285 FastLED.show(); 286 } 287 288 289 290 Serial.print(':'); 291 Serial.print(now.second(), DEC); 292 Serial.println(); 293 294 295 296 Serial.println(); 297 delay(3000); 298} 299
Downloadable files
WORDCLOCK2812
WORDCLOCK2812
WORDCLOCK2812
WORDCLOCK2812
Comments
Only logged in users can leave comments
girishrajg
5 years ago
How do you adjust the time?