/************************************************************************** * * * W O R D C L O C K - A clock that tells the time using words. * * * * ELGLISH LANGUAGE SUPPORT FILE * * * * Hardware: Arduino Dumelove with a set of individual LEDs under a word * * stencil. * * * * Copyright (C) 2009 Doug Jackson (doug@doughq.com) * * * *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * * MA 02111-1307 USA * * * *************************************************************************** * * Revision History * * Date By What */ // Display output pin assignments #define MINUTES Display1=Display1 | (1<<0); Serial.print("Minutes "); #define MTEN Display1=Display1 | (1<<1); Serial.print("ten "); #define HALF Display1=Display1 | (1<<2); Serial.print("half "); #define PAST Display1=Display1 | (1<<3); Serial.print("past "); #define THREE Display1=Display1 | (1<<4); Serial.print("three "); #define ITIS Display1=Display1 | (1<<5); Serial.print("It is "); #define TWENTY Display1=Display1 | (1<<6); Serial.print("twenty "); #define TO Display1=Display1 | (1<<7); Serial.print("to "); #define TWO Display2=Display2 | (1<<0); Serial.print("two "); #define SIX Display2=Display2 | (1<<1); Serial.print("six "); #define TWELVE Display2=Display2 | (1<<2); Serial.print("twelve "); #define HFIVE Display2=Display2 | (1<<3); Serial.print("five "); #define SEVEN Display2=Display2 | (1<<4); Serial.print("seven "); #define OCLOCK Display2=Display2 | (1<<5); Serial.print("oclock "); #define ONE Display2=Display2 | (1<<6); Serial.print("one "); #define QUARTER Display2=Display2 | (1<<7); Serial.print("quarter "); #define EIGHT Display3=Display3 | (1<<0); Serial.print("eight "); #define MFIVE Display3=Display3 | (1<<1); Serial.print("five "); #define ELEVEN Display3=Display3 | (1<<3); Serial.print("eleven "); #define HTEN Display3=Display3 | (1<<4); Serial.print("ten "); #define NINE Display3=Display3 | (1<<5); Serial.print("nine "); #define FOUR Display3=Display3 | (1<<6); Serial.print("four "); #define WORD1 Display3=Display3 | (1<<7); Serial.print("word1 "); #define WORD2 Display3=Display3 | (1<<2); Serial.print("word2 "); #define WORD1OFF Display3=Display3 & ~(1<<7); #define WORD2OFF Display3=Display3 & ~(1<<2); #define LED1 Led1=1; Serial.print("MINLED 1 ") #define LED2 Led2=1; Serial.print("2 ") #define LED3 Led3=1; Serial.print("3 ") #define LED4 Led4=1; Serial.print("4 ") void selftest(void){ // start by clearing the display to a known state ledsoff(); ITIS; delay(500); ledsoff(); HALF; delay(500); ledsoff(); MTEN; delay(500); ledsoff(); QUARTER; delay(500); ledsoff(); TWENTY; delay(500); ledsoff(); MFIVE; delay(500); ledsoff(); MINUTES; delay(500); ledsoff(); TO; delay(500); ledsoff(); PAST; delay(500); ledsoff(); ONE; delay(500); ledsoff(); THREE; delay(500); ledsoff(); TWO; delay(500); ledsoff(); FOUR; delay(500); ledsoff(); HFIVE; delay(500); ledsoff(); SIX; delay(500); ledsoff(); SEVEN; delay(500); ledsoff(); EIGHT; delay(500); ledsoff(); NINE; delay(500); ledsoff(); HTEN; delay(500); ledsoff(); ELEVEN; delay(500); ledsoff(); TWELVE; delay(500); ledsoff(); OCLOCK; delay(500); ledsoff(); WORD1; delay(500); ledsoff(); WORD2; delay(500); ledsoff(); LED1; delay(500); ledsoff(); LED2; delay(500); ledsoff(); LED3; delay(500); ledsoff(); LED4; delay(500); for(int i=0; i<5; i++) { Display1=255; Display2=255; Display3=255; delay(500); ledsoff(); delay(500); } } void displaytime(void){ // start by clearing the display to a known state ledsoff(); // Now, turn on the "It is" leds ITIS; // now we display the appropriate minute counter if ((minute>4) && (minute<10)) { MFIVE; MINUTES; } if ((minute>9) && (minute<15)) { MTEN; MINUTES; } if ((minute>14) && (minute<20)) { QUARTER; } if ((minute>19) && (minute<25)) { TWENTY; MINUTES; } if ((minute>24) && (minute<30)) { TWENTY; MFIVE; MINUTES; } if ((minute>29) && (minute<35)) { HALF; } if ((minute>34) && (minute<40)) { TWENTY; MFIVE; MINUTES; } if ((minute>39) && (minute<45)) { TWENTY; MINUTES; } if ((minute>44) && (minute<50)) { QUARTER; } if ((minute>49) && (minute<55)) { MTEN; MINUTES; } if (minute>54) { MFIVE; MINUTES; } if ((minute <5)) { switch (hour) { case 1: case 13: ONE; break; case 2: case 14: TWO; break; case 3: case 15: THREE; break; case 4: case 16: FOUR; break; case 5: case 17: HFIVE; break; case 6: case 18: SIX; break; case 7: case 19: SEVEN; break; case 8: case 20: EIGHT; break; case 9: case 21: NINE; break; case 10: case 22: HTEN; break; case 11: case 23: ELEVEN; break; case 0: case 12: TWELVE; break; } OCLOCK; } else if ((minute < 35) && (minute >4)) { PAST; switch (hour) { case 1: case 13: ONE; break; case 2: case 14: TWO; break; case 3: case 15: THREE; break; case 4: case 16: FOUR; break; case 5: case 17: HFIVE; break; case 6: case 18: SIX; break; case 7: case 19: SEVEN; break; case 8: case 20: EIGHT; break; case 9: case 21: NINE; break; case 10: case 22: HTEN; break; case 11: case 23: ELEVEN; break; case 0: case 12: TWELVE; break; } } else { // if we are greater than 34 minutes past the hour then display // the next hour, as we will be displaying a 'to' sign TO; switch (hour) { case 1: case 13: TWO; break; case 2: case 14: THREE; break; case 3: case 15: FOUR; break; case 4: case 16: HFIVE; break; case 5: case 17: SIX; break; case 6: case 18: SEVEN; break; case 7: case 19: EIGHT; break; case 8: case 20: NINE; break; case 9: case 21: HTEN; break; case 10: case 22: ELEVEN; break; case 11: case 23: TWELVE; break; case 0: case 12: ONE; break; } } // now we can illuminate the extra minute LEDs if ((minute-(minute/5)*5)==1) { LED1; } if ((minute-(minute/5)*5)==2) { LED1; LED2; } if ((minute-(minute/5)*5)==3) { LED1; LED2; LED3; } if ((minute-(minute/5)*5)==4) { LED1; LED2; LED3; LED4; } if (( minute==0) && (second==0)) { Serial.println("ALARM!!"); WORD1; delay(500); WORD1OFF; delay(500); WORD2; delay(500); WORD2OFF; delay(500); WORD1; delay(300); WORD1OFF; delay(300); WORD2; delay(300); WORD2OFF; delay(300); WORD1; delay(200); WORD1OFF; delay(200); WORD2; delay(200); WORD2OFF; delay(200); WORD1; delay(500); WORD1OFF; delay(500); WORD2; delay(500); WORD2OFF; delay(500); WORD1; delay(300); WORD1OFF; delay(300); WORD2; delay(300); WORD2OFF; delay(300); WORD1; delay(200); WORD1OFF; delay(200); WORD2; delay(200); WORD2OFF; delay(200); } }