├── README.md ├── clockFace.svg ├── template.svg └── wordClockCode.ino /README.md: -------------------------------------------------------------------------------- 1 | # arduino-neopixel-word-clock 2 | Arduino code + SVG files for Arduino + Neopixel Word Clock featured in Super Make Something Episode 6 3 | 4 | Instructions for this project can be found here: https://youtu.be/6tMTQ7Khe90 5 | 6 | by: Alex - Super Make Something 7 | 8 | date: August 16, 2015 9 | 10 | license: Creative Commons - Attribution - Non-Commercial. More information available at: http://creativecommons.org/licenses/by-nc/3.0/ 11 | 12 | additional: modified from "simple.ino" NeoPixel example sketch by Shae Erisson of Adafruit Industries. 13 | 14 | notes: 15 | 16 | REQUIRES NEOPIXEL & TIME LIBRARIES TO BE INSTALLED UNDER ...\Arduino\libraries 17 | 18 | NEOPIXEL LIBRARY AVAILABLE AT: https://github.com/adafruit/Adafruit_NeoPixel 19 | 20 | TIME LIBRARY AVAILABLE AT: https://github.com/PaulStoffregen/Time 21 | -------------------------------------------------------------------------------- /wordClockCode.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Arduino + Neopixel Word Clock Code 4 | by: Alex - Super Make Something 5 | date: August 16, 2015 6 | license: Public domain. Please use, reuse, and modify this sketch! 7 | additional: modified from "simple.ino" NeoPixel example sketch by Shae Erisson of Adafruit Industries. 8 | 9 | NOTE: REQUIRES NEOPIXEL & TIME LIBRARIES TO BE INSTALLED UNDER ...\Arduino\libraries 10 | NEOPIXEL LIBRARY AVAILABLE AT: https://github.com/adafruit/Adafruit_NeoPixel 11 | TIME LIBRARY AVAILABLE AT: https://github.com/PaulStoffregen/Time 12 | 13 | Explanation: This code lights up Neopixels corresponding to the current time. 14 | Time is kept using the time library. 15 | Neopixels are lit using the Adafruit Neopixel library. 16 | 17 | Depending on the current time, flags to light corresponding Neopixels are saved in an array 18 | After parsing the time, Neopixels are turned on/off according to the flags using a for loop 19 | 20 | */ 21 | 22 | #include 23 | #include 24 | #include "Time.h" 25 | 26 | // Which pin on the Arduino is connected to the NeoPixels? 27 | #define PIN 3 28 | 29 | // How many NeoPixels are attached to the Arduino? 30 | #define NUMPIXELS 32 31 | 32 | // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. 33 | // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest 34 | // example for more information on possible values. 35 | Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); 36 | 37 | // Declare integer array with size corresponding to number of Neopixels in chain 38 | // int individualPixels[NUMPIXELS]; 39 | 40 | //Declare pins for decrementing/incrementing current time by 5 minutes 41 | #define MINUSFIVEMINS 4 42 | #define PLUSFIVEMINS 5 43 | 44 | //Declare pins for addition button 5V/GND sources 45 | #define BUTTONLEDMINUS_GND1 8 46 | #define BUTTONLEDMINUS_GND2 9 47 | #define BUTTONLEDPLUS_GND1 10 48 | #define BUTTONLEDPLUS_GND2 11 49 | 50 | #define BUTTONLEDMINUS_5V1 A0 51 | #define BUTTONLEDMINUS_5V2 A1 52 | #define BUTTONLEDPLUS_5V1 A2 53 | #define BUTTONLEDPLUS_5V2 A3 54 | 55 | // Current and previous states for button pins -- in setup initialize all to HIGH 56 | int minusPrevState=HIGH; 57 | int minusCurrState=HIGH; 58 | int plusPrevState=HIGH; 59 | int plusCurrState=HIGH; 60 | 61 | // Time variables 62 | int h; 63 | int m; 64 | int s; 65 | 66 | // RGB color variables 67 | int red=0; 68 | int green=0; 69 | int blue=255; 70 | 71 | void setup() 72 | { 73 | 74 | pinMode(MINUSFIVEMINS, INPUT_PULLUP); //Define pin as input, enable pull-up resistor 75 | pinMode(PLUSFIVEMINS, INPUT_PULLUP); //Define pin as input, enable pull-up resistor 76 | pinMode(BUTTONLEDMINUS_GND1, OUTPUT); //Define pin as output 77 | pinMode(BUTTONLEDMINUS_GND2, OUTPUT); //Define pin as output 78 | pinMode(BUTTONLEDPLUS_GND1, OUTPUT); //Define pin as output 79 | pinMode(BUTTONLEDPLUS_GND2, OUTPUT); //Define pin as output 80 | pinMode(BUTTONLEDMINUS_5V1, OUTPUT); //Define pin as output 81 | pinMode(BUTTONLEDMINUS_5V2, OUTPUT); //Define pin as output 82 | pinMode(BUTTONLEDPLUS_5V1, OUTPUT); //Define pin as output 83 | pinMode(BUTTONLEDPLUS_5V2, OUTPUT); //Define pin as output 84 | 85 | digitalWrite(BUTTONLEDMINUS_GND1, LOW); //Set pin value to LOW 86 | digitalWrite(BUTTONLEDMINUS_GND2, LOW); //Set pin value to LOW 87 | digitalWrite(BUTTONLEDPLUS_GND1, LOW); //Set pin value to LOW 88 | digitalWrite(BUTTONLEDPLUS_GND2, LOW); //Set pin value to LOW 89 | digitalWrite(BUTTONLEDMINUS_5V1, HIGH); //Set pin value to HIGH 90 | digitalWrite(BUTTONLEDMINUS_5V2, HIGH); //Set pin value to HIGH 91 | digitalWrite(BUTTONLEDPLUS_5V1, HIGH); //Set pin value to HIGH 92 | digitalWrite(BUTTONLEDPLUS_5V2, HIGH); //Set pin value to HIGH 93 | 94 | setTime(12,0,0,31,8,2015); //Initialize current time as Midnight/noon 08/31/2015 95 | pixels.begin(); //Begin Neopixel string 96 | Serial.begin(9600); //Begin Serial for debugging purposes 97 | 98 | } 99 | 100 | void loop() 101 | { 102 | 103 | //Declare integer array with size corresponding to number of Neopixels in chain 104 | int individualPixels[NUMPIXELS]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 105 | 106 | /* Check for button presses & reset time if necessary */ 107 | minusCurrState=digitalRead(MINUSFIVEMINS); //Get current state of MINUSFIVEMINS button 108 | /* If current state is different from previous state and value is now LOW, subtract five minutes from current time */ 109 | if ((minusCurrState!=minusPrevState) && (minusCurrState==LOW)){ 110 | adjustTime(-5*60); //Shift time five minutes backwards 111 | minusPrevState=minusCurrState; 112 | } 113 | else{ 114 | minusPrevState=minusCurrState; 115 | } 116 | 117 | plusCurrState=digitalRead(PLUSFIVEMINS); //Get current state of PLUSFIVEMINS button 118 | /* If current state is different from previous state and value is now LOW, add five minutes from current time */ 119 | if ((plusCurrState!=plusPrevState) && (plusCurrState==LOW)){ 120 | adjustTime(5*60); //Shift time five minutes forwards 121 | plusPrevState=plusCurrState; 122 | } 123 | else{ 124 | plusPrevState=plusCurrState; 125 | } 126 | 127 | /* Get current time */ 128 | h=hourFormat12(); // Returns the hour of current time between 1-12 129 | m=minute(); // Returns the minute of current time 130 | s=second(); // Returns the second of current time (not used, included for completeness) 131 | 132 | Serial.print(h); 133 | Serial.print(":"); 134 | Serial.print(m); 135 | Serial.print(":"); 136 | Serial.println(s); 137 | 138 | /* Parse time values to light corresponding pixels */ 139 | individualPixels[0]=1; //Light "IT" 140 | individualPixels[1]=1; //Light "IS" 141 | 142 | /* Minutes between 0-5 - Light "O CLOCK" */ 143 | if ((m>=0 && m<5)){ 144 | individualPixels[28]=1; 145 | individualPixels[29]=1; 146 | } 147 | 148 | /* Minutes between 5-10 or 55-60 - Light "FIVE," "MINUTES" */ 149 | if ((m>=5 && m<10) || (m>=55 && m<60)){ 150 | individualPixels[8]=1; 151 | individualPixels[9]=1; 152 | individualPixels[10]=1; 153 | } 154 | 155 | /* Minutes between 10-15 or 50-55 - Light "TEN," "MINUTES" */ 156 | if ((m>=10 && m<15) || (m>=50 && m<55)){ 157 | individualPixels[2]=1; 158 | individualPixels[9]=1; 159 | individualPixels[10]=1; 160 | } 161 | 162 | /* Minutes between 15-20 or 45-50 - Light "QUARTER" */ 163 | if ((m>=15 && m<20) || (m>=45 && m<50)){ 164 | individualPixels[6]=1; 165 | individualPixels[7]=1; 166 | } 167 | 168 | /* Minutes between 20-25 or 40-45 - Light "TWENTY," "MINUTES" */ 169 | if ((m>=20 && m<25) || (m>=40 && m<45)){ 170 | individualPixels[4]=1; 171 | individualPixels[5]=1; 172 | individualPixels[9]=1; 173 | individualPixels[10]=1; 174 | } 175 | 176 | /* Minutes between 25-30 or 35-40 - Light "TWENTY," "FIVE," "MINUTES" */ 177 | if ((m>=25 && m<30) || (m>=35 && m<40)){ 178 | individualPixels[4]=1; 179 | individualPixels[5]=1; 180 | individualPixels[8]=1; 181 | individualPixels[9]=1; 182 | individualPixels[10]=1; 183 | } 184 | 185 | /* Minutes between 30-35 - Light "HALF" */ 186 | if ((m>=30 && m<35)){ 187 | individualPixels[3]=1; 188 | } 189 | 190 | /* Minutes between 5-35 - Light "PAST" */ 191 | if ((m>=5) && (m<35)){ 192 | individualPixels[14]=1; 193 | } 194 | 195 | /* Minutes between 35-60 - Light "TO" & MODIFY CURRENT HOUR VALUE */ 196 | if (m>=35){ 197 | individualPixels[13]=1; 198 | h++; //Add 1 from current hour 199 | /*Set time to twelve for hour around midnight, noon */ 200 | if (h==0){ 201 | h=12; 202 | } 203 | /*Corner case for 12:35-12:59 */ 204 | if (h==13){ 205 | h=1; 206 | } 207 | } 208 | 209 | /* Hour=1 - Light "ONE" */ 210 | if (h==1){ 211 | individualPixels[12]=1; 212 | } 213 | 214 | /* Hour=2 - Light "TWO" */ 215 | if (h==2){ 216 | individualPixels[11]=1; 217 | } 218 | 219 | /* Hour=3 - Light "THREE" */ 220 | if (h==3){ 221 | individualPixels[15]=1; 222 | individualPixels[16]=1; 223 | } 224 | 225 | /* Hour=4 - Light "FOUR" */ 226 | if (h==4){ 227 | individualPixels[17]=1; 228 | } 229 | 230 | /* Hour=5 - Light "FIVE" */ 231 | if (h==5){ 232 | individualPixels[18]=1; 233 | } 234 | 235 | /* Hour=6 - Light "SIX" */ 236 | if (h==6){ 237 | individualPixels[23]=1; 238 | } 239 | 240 | /* Hour=7 - Light "SEVEN" */ 241 | if (h==7){ 242 | individualPixels[21]=1; 243 | individualPixels[22]=1; 244 | } 245 | 246 | /* Hour=8 - Light "EIGHT" */ 247 | if (h==8){ 248 | individualPixels[19]=1; 249 | individualPixels[20]=1; 250 | } 251 | 252 | /* Hour=9 - Light "NINE" */ 253 | if (h==9){ 254 | individualPixels[24]=1; 255 | } 256 | 257 | /* Hour=10 - Light "TEN" */ 258 | if (h==10){ 259 | individualPixels[25]=1; 260 | } 261 | 262 | /* Hour=11 - Light "ELEVEN" */ 263 | if (h==11){ 264 | individualPixels[26]=1; 265 | individualPixels[27]=1; 266 | } 267 | 268 | /* Hour=12 - Light "TWELVE" */ 269 | if (h==12){ 270 | individualPixels[30]=1; 271 | individualPixels[31]=1; 272 | } 273 | 274 | /* Light pixels corresponding to current time */ 275 | for (int i=0; i