Wake Up! (prototype)
Posted by Nate in Projects.
Friday, October 19th, 2007 at 2:42 pm
Argh! So close! Last night was the first night I tried to test the new wakeup system (it feels weird to call it an alarm, but wakeup system is too long..?) and it went pretty well – until morning, that is. Then, as planned, there were birds twittering nicely, but the room remained sadly dark. And, totally ruining the intended effect, I was thinking about it all night and kept waking up to see what time it was and when it was supposed to go off!
So, clearly not working yet. Let’s back up… I ended up with a Sony ICF-CD815 Dream Machine CD / radio alarm clock, a nice looking unit with dual alarms. I can imagine a scenario where one of us has to get up at some terrible hour, and can use one built-in alarm, leaving the second one to trigger the system later for a gentle wakeup.
Speaking of "trigger the system", that’s where my troubles began: I needed a way to tell the Arduino that the alarm was going off. I had toyed with the idea of watching voltage across the CD motor, etc, but ruled this out because we’d never be able to play CDs in the room without starting up the light dimmer! After pulling apart and testing everything I could think to test with just a multimeter (if I keep doing this I’m getting an oscilloscope), I decided to tie into the LED for Alarm A. By attaching my own light here, I could create a signal outside the clock that I hoped I could detect with the Arduino.
It wasn’t that easy. The light can be either solid on or solid off depending on if the alarm is set or not, and it goes to a "flashing" state when the alarm is actually going off. Hmm. I wrote and tested numerous versions of code to watch for resistance changes in a light-sensitive resistor, and went to bed believing I had it nailed.
The complication lies in the poor sampling ability of the resistor (that pulse line above is actually pretty wavy) and the timing issue of the blinks: no matter what I tried, the code would sometimes miss a blink, and decide the alarm was over. What I ended up doing was keeping track of the last 8 samples and counting state changes. If I could say that the light "changed" (beyond a certain threshold) at least 3 times out of 8, it was "blinking". This leads to a little bit of lag – 8 samples takes about 5 seconds – but it seems to be working.
… of course, I didn’t get that sample size right until too late. This morning some combination of being in the dark and possibly a loose connector left the whole thing inoperable. Dag. Always tomorrow morning, I guess!
At right: the little guy making it all happen. (The Arduino board is actually under the piece you can see.) The three clear LEDs are for temporary lighting, the red one represents the furnace until I run that wire, and the buzzer is for the backup alarm. That blue-tape-wrapped thingy on the top is the Alarm A LED glued to a photoresistor for sample the alarm light. Once I get it finalized I’ll put it all on a new circuit board and in a nice box. Also still waiting for the final dimmer kit to arrive… Fun!
(oh, and there’s an output pin standing by to fire the coffee pot in version 2… :)
Similar Posts:
- Time for a project! ( October, 2007)
- Detox Redux ( May, 2006)
- Aunty Baby ( March, 2006)
- Some weather guy’s getting fired… ( February, 2007)
- Wah ( November, 2005)
October 19th, 2007 at 5:22 pm
I have no idea what you are talking about in pretty much this entire post. But I think you’re super dreamy.
October 19th, 2007 at 7:06 pm
All I can say is thank god your on the good guys side.
October 19th, 2007 at 7:13 pm
Oh, a name suggestion:
R.O.O.S.T.E.R.
Really Omnipotent Operating Subtlely To Ease Reality
Ok, so I was BS’ing the initialls, I still like it. ;)
October 19th, 2007 at 8:26 pm
That’s pretty damn sweet! Did you have a lot of these parts just lying around? Or did you start with new materials?
And what’s this nonsense about the Arduino not being able to sample fast enough to catch the flashing? That’s dumb. You should make it faster. ;)
So, what’s the software interface for that bad boy look like? Are you writing Java code at an API for the Arduino? I want you to post your code! Hehe. Or not.
October 23rd, 2007 at 8:03 am
huh?