1. Introduction
In this post I want to describe a Christmas Magic Advent Calendar project I have been working on recently (with some awesome help from the family). This project is best described as my take/dream on Advent Calendar. I think we all know how these things typically work and we all have enjoyed them in our childhood - I know I have. For those that don't know it is a way of tracking how many days are left util Christmas while eating getting to eat chocolate or cookies. Basically calendar starts on December 1st and goes until December 24th and there is chocolate hidden behind each door. You are supposed to open the door on each day and get your chocolate - what an amazing way of waiting for Christmas. However, you are not supposed to open any future days! I always loved these things and one day while on a 5 hour driving trip me and me wife, for whatever reason started having this idea of building our own smart, fun advent calendar. We jotted all the ideas and requirements we wanted this to have and the project was born from the idea.
2. Steps
We knew we wanted the calendar to look like a little house that we could decorate in the end to have Christmas look. We had this idea of maybe having drawer that would slide out and we would determine if it is correct day. However, we quickly realized that in order to incorporate electronics and cookies the structure will have to be pretty big. So the wood work started, with help of my father in law we built the skeleton and in the process we decided it would be better to use sliding plexi glass, and incorporate switches underneath it, rather than using drawer with switches behind them. After a lot of cutting and drilling, and gluing and sanding and being patient , or at least trying to be the the skeleton of the house was created.
After the frame was completed it was time for getting the spirit of the Christmas Magic ready. And by "Spirit" I mean 24 switches, 25 LEDs, 2 speakers, 2 micro controllers, logic shifter, real time clock, sound shields, 2 MCP23017 16 bit IO expanders all connected or soldered together. Offff that was a mouthful, let me just say that I typically enjoy soldering and connecting electronics, but after all this even I was getting a bit tired. Let's allow some more pictures to do the talking.
Once all of those lovely wires were connected together and ran through generic testing, my wife and I focused on decorating the house to make it look pretty. Wife's input on how to make it look nice was huge since I would have probably just painted it or maybe not even painted it and called it a day. I am pretty sure though wifey's ideas were better and the end effect turned out pretty awesome if I might say.
Also, do you see those cookies behind the door? Those are home made by my wife and her mom and I swear they will make me big, but I don't care.
3. How it works
Please before you start reading how this section go ahead and watch the videos!
Now come back to this section and prepare to be amazed by seeing that all functionality presented
was achieved with following lines of code:
void loop() {
resController.execute();
debugLogger.log("Out of resource controller\n");
delay(80);
}
Bammmmmmmm! Just kidding, the way the system works in high level overview is as follow. There are
24 switches each corresponding to a door. Switches are connected to two 16 bits IO expanders which are then connected
to feather microcontroller over I2C. Feather is also connected to 25 Neopixels, 24 of them are in one chain while one is separate.
(Yes, yes they probably could have been all connected together, but that last one was kind of an after thought).
Next very crucial part of the system is real time clock which again is interfaced to feather using I2C. Feather is then
connected to Arduino with music shield. Why two separate micros one might ask? Well for the most part that is because I already had the music shield for the Arduino
and was going to initially just use Arduino for the entire project, but quickly found out that this was not possible. Without making a long store
Arduino didn't like extended functionality of reading switches, playing music, reading serial while controlling Neopixels.
In the end I actually don't mind dual setup since it is super easy to sync up the lights and music without having to look into separting tasks etc.
Also, my understanding is that Neopixel library disables the interrupts due to strict timing requirements, while music shield relies
on interrupts to feed the song data. With two separate micros this is not an issue (if you look at the Github code I am using digital input for interfacing between micros,
I will possibly change that in the future to simply use serial protocol of sort).
In high level overview of the software (since I am running out of time before midnight deadline!) it does the following:
- Read the date, if the date is 12/1 trigger the start of the calendar
- If the door is opened, identify which door it was and if it corresponds to current date
- If the door date is later than current date, inform the user of the huge mistake! It is not time for that cookie yet!
- If the door date is equal or earlier than current day and all the previous doors have been opened, let the user know it is time for that cookie!
- Repeat the process until it gets to December 24th. After December 24th is opened trigger the end of calendar and turn all the lights off.
- Wait until December 1st to trigger again and eat more cookies.
For more information about the software please head to the Github page: (https://github.com/archieLa/ChristmasMagic) If there is anything you are interested in that the code can't answer please reach out and I will!
I can even share some cookies!
For reference of connections please see the image below exported from Fritzing.
4. Video presentation and pictures while it is working
Introduction video
And finally! Our doggy loves the Christmas Magic or just the cookies, but either way that picture is awesome:):)!
Top Comments