Ahmed Mohamed inspired clock

Hey, everyone! Partly inspired by Ahmed Mohamed, I have made a clock using an Arduino Pro Mini, four MAX7219 LED arrays, a DS3231 real time clock, and a keypad salvaged from an old digital clock. It stores things like whether or not to display military time in the Arduino’s EEPROM. So far it has no alarm, but there are a lot of things that can be done to it via the serial terminal, which parses input and responds to commands. The time and date (the latter of which it doesn’t normally display, but could be used if I implement an alarm system) can all be set via the keypad, which brings up a simple paging editor that shows a blinking cursor on the data to be edited (this was the trickiest part to implement; with MAX7219s, you have to handle cursors all by yourself).

The source is attached

and you can watch video of it here:

Commands that can be issued via the serial terminal (at 19200 baud!) include:

ae - animate explosion (a visual display to tweak the Ahmed haters)
bs - blink screen
cs - clear screen
pc - print a string of date/time info
pT - print current unix timestamp (2000 based, not 1970 based!)
pDb0 [LOC] – print a byte from Arduino EEPROM
pDi0 [LOC] – print an int from Arduino EEPROM
pDl0 [LOC] – print a long from Arduino EEPROM
r - reset (sort of; needs work)
scd [YY:MM:DD] - set clock date
sct [HH:MM:ss] - set clock time
scw [DoW] - set day of week
sDb0 [LOC, VALUE] – set a byte in Arduino EEPROM
sDi0 [LOC, VALUE] – set an int in Arduino EEPROM
sDl0 [LOC, VALUE] – set a long in Arduino EEPROM
sdm [1 or 0] - set display military (yes or no)
sds [1 or 0] - set display seconds (yes or no to show seconds or not)
si [intensity] - set display intensity
stm[message] - set temporary message – shows a message briefly on the display
stt [milliseconds] - time to display temporary message

By the way: those interested in the little “suitcase” Ahmed Mohamed used for his clock reboxing, it’s a Vaultz Personal Lockbox. You can get one on eBay for $16. http://www.ebay.com/itm/Vaultz-Locking-Pencil-Box-8-25-x-5-5-x-2-5-Inches-Black-VZ01479-OOO-NEW-/111646504333?hash=item19fea6758d

His NASA teeshirt (for the full Halloween costume) could be this one:

gus_clock_151119.ino (84.4 KB)

Not to discredit your creation, but looking at a picture of Ahmed's clock it's apparent he just tore apart a 120V AC alarm clock and threw it in a suitcase.

this is supposed to be a multi-prong satire (and a usable clock). on the one hand, unlike ahmed's clock, which it superficially resembles, it is a real clock made essentially from scratch, but it also has a function to display a fake "explosion" -- because that is another false expectation for the projects of tech-savvy brown-skinned boys. i'm working on adding an audio feature to make explosion noises to accompany the visual display and to also do the muezzin's adhan at the push of a button (or on the hour). another button triggers the "ayyyeaaaaah... ah!" from led zepplin's immigrant song. an update will be uploaded when i have implemented these things.

bigfun: i'm working on adding an audio feature .... to also do the muezzin's adhan at the push of a button (or on the hour).

Or at the right times, if you're up for a challenge.

true, if it's an adhan, it shouldn't be on the hour. but i know precisely the time and date, so getting that right should be possible, although it looks like it would either require including a gps module or the user entering their present latitude and longitude.

EDIT: yikes, there is lots of math in doing that! i haven't yet had to do a floating point calculation on an Arduino, and it's doubtful i will start on this project.

bigfun: true, if it's an adhan, it shouldn't be on the hour. but i know precisely the time and date, so getting that right should be possible, although it looks like it would either require including a gps module or the user entering their present latitude and longitude.

EDIT: yikes, there is lots of math in doing that! i haven't yet had to do a floating point calculation on an Arduino, and it's doubtful i will start on this project.

I suppose you could use a lookup table for the trig.

I generated a table by doing this: http://ideone.com/9bd2kF

The table itself:

    0,   101,   201,   302,   402,   503,   603,   704,
  804,   904,  1005,  1105,  1205,  1306,  1406,  1506,
 1606,  1706,  1806,  1906,  2006,  2105,  2205,  2305,
 2404,  2503,  2603,  2702,  2801,  2900,  2999,  3098,
 3196,  3295,  3393,  3492,  3590,  3688,  3786,  3883,
 3981,  4078,  4176,  4273,  4370,  4467,  4563,  4660,
 4756,  4852,  4948,  5044,  5139,  5235,  5330,  5425,
 5520,  5614,  5708,  5803,  5897,  5990,  6084,  6177,
 6270,  6363,  6455,  6547,  6639,  6731,  6823,  6914,
 7005,  7096,  7186,  7276,  7366,  7456,  7545,  7635,
 7723,  7812,  7900,  7988,  8076,  8163,  8250,  8337,
 8423,  8509,  8595,  8680,  8765,  8850,  8935,  9019,
 9102,  9186,  9269,  9352,  9434,  9516,  9598,  9679,
 9760,  9841,  9921, 10001, 10080, 10159, 10238, 10316,
10394, 10471, 10549, 10625, 10702, 10778, 10853, 10928,
11003, 11077, 11151, 11224, 11297, 11370, 11442, 11514,
11585, 11656, 11727, 11797, 11866, 11935, 12004, 12072,
12140, 12207, 12274, 12340, 12406, 12472, 12537, 12601,
12665, 12729, 12792, 12854, 12916, 12978, 13039, 13100,
13160, 13219, 13279, 13337, 13395, 13453, 13510, 13567,
13623, 13678, 13733, 13788, 13842, 13896, 13949, 14001,
14053, 14104, 14155, 14206, 14256, 14305, 14354, 14402,
14449, 14497, 14543, 14589, 14635, 14680, 14724, 14768,
14811, 14854, 14896, 14937, 14978, 15019, 15059, 15098,
15137, 15175, 15213, 15250, 15286, 15322, 15357, 15392,
15426, 15460, 15493, 15525, 15557, 15588, 15619, 15649,
15679, 15707, 15736, 15763, 15791, 15817, 15843, 15868,
15893, 15917, 15941, 15964, 15986, 16008, 16029, 16049,
16069, 16088, 16107, 16125, 16143, 16160, 16176, 16192,
16207, 16221, 16235, 16248, 16261, 16273, 16284, 16295,
16305, 16315, 16324, 16332, 16340, 16347, 16353, 16359,
16364, 16369, 16373, 16376, 16379, 16381, 16383, 16384,
16384

It's a table of sines from 0 to 90 degrees, with each "step" being 1/256 of a right angle (that is, 0.3515625 degree, or about 0.00613592 radian, or exactly 1/1024 of a full turn). All the numbers in the table are 16384 times the mathematically correct value. This factor, 16384, equals 2 to the 14th power.

Here’s a new update of the clock, which now features a WTV020SD audio card connected via D13-D16. Didn’t know Arduino has D14 and up? Using those pins will make digital stuff happen on the Analog pins, and I didn’t have much use for analog on this clock. New commands that can be issued via serial include

vv[number] – voice the numbered voice on the micro-sd card in the WTV020SD
sbo [1 or 0] – turn hourly chimes on
sbr [hour1, hour2] – range of hours when hourly chimes can happen (ie, not at night)
svb [number] – sound file for use in hourly chimes
sve [number] – sound file for use in animating explosions. New software will be uploaded.

gus_clock-151013.ino (67.4 KB)

Here is the latest version of the clock code. It now supports half hour chimes and ten alarms that can be set for dates or to repeat on a daily basis. Unfortunately, alarms have to be set via the serial interface; I’ve yet to build a UI to set those using the buttons. Here are the new serial commands:

pa[number of alarm] – print out the settings for one of the alarms (0-9)
sad[number of alarm] [month]/[dayOfMonth] – set alarm date (if no date set, alarm repeats every day)
sat[number of alarm] [hour]:[minute] – set alarm time (must use military)
sva[number of alarm] [number of voice] – set the audio file for the alarm

gus_clock_15_10_25.ino (76.4 KB)

Here's another video of the clock:|500x242

https://www.youtube.com/watch?v=Blc6tc-b8DQ&feature=youtu.be

bigfun: Here is the latest version of the clock code. It now supports half hour chimes and ten alarms that can be set for dates or to repeat on a daily basis. Unfortunately, alarms have to be set via the serial interface; I've yet to build a UI to set those using the buttons. Here are the new serial commands:

pa[number of alarm] -- print out the settings for one of the alarms (0-9) sad[number of alarm] [month]/[dayOfMonth] -- set alarm date (if no date set, alarm repeats every day) sat[number of alarm] [hour]:[minute] -- set alarm time (must use military) sva[number of alarm] [number of voice] -- set the audio file for the alarm

OK, but you do you "un-set" (i.e. deactivate) one of the alarms?

ah, good point. for now, setting the year to less than 2015 will do the trick. i forgot to mention the set year command ("say"). to disable alarm 0, issue

say 0,2014

over the serial terminal

I just uploaded a new version supporting countdown and stopwatch functions, accessible via the keypad and the serial terminal. The keypad now has buttons dedicated to Mode (‘M’), Clear (‘C’), and Start/Stop (’!’). If mode is pushed, the clock cycles between three modes: normal time, coundown, and count up. If in coundown mode, you get an editor allowing the start time to be altered. Then start will initiate the countdown. After that, start becomes stop. Clear will reset the time to the previous time to countdown from.

If in countup mode, start initiates count up, etc. Note: because of the limits of the display, currently count up and countdown are limited to 99 minutes, 59 seconds and 9 tenths. (Both count up and down are granular to tenth of a second).

From the serial terminal, these new commands apply:

sC – set countdown time (in deciseconds – sorry, ugly!)
i[increment positive or negative] – initiates either a countdown or countup.

gus_clock_151117.ino (85.2 KB)

here’s a new version with some minor bug fixes and a more accurate algorithm for the stopwatch/countdown modes.

gus_clock_151119.ino (84.4 KB)