Here is the recent meme that inspired this project: https://www.youtube.com/watch?v=daTeIK57pPU
The emphasis is clearly on the audio. Video just helps to contextualize the energized preacher :)
You don't have to use the "wake up wake up" video clip. This will work for any video. Pick whatever video makes you happiest to wake up to! Or pick a dreadful video and give it to someone as a goof?
The biggest surprise of this project is that I did not use RaspberryPi. I used Teensy 3.6! A RaspberryPi version is also possible, although not nearly as badass as playing audio/video from a Teensy. Teensy is dope. Can easily program it with Arduino IDE. Out of this world audio capabilities. Does video. On board SD slot. Extremely compact. Lots of pins and effortless to interface with encoders/switches/etc.
Like many of these projects, the work was in the code. With the code being written for you, this Instructable should be a breeze!
Project of the week on Maker Update – https://www.youtube.com/watch?v=N0zTETpJoww
Step 1: Parts & Software
- Teensy 3.6 microcontroller (I think it may also be possible from an overclocked Teensy 3.2. Can someone confirm?)
- ILI9341 display (many cheaper options on eBay and Aliexpress). I used a 2.4", but also comes in 2.8".
- 3W speaker x1
- 2.5W mono amp x1
- Rotary encoder x2
- Three way switch x1
- Toggle switch x1
- Micro SD card
- Typical: wire, solder, etc.
- Frank's ILI9341 DMA buffer library
- Video editing software (I used Premiere)
- FFMPEG (command line video tools – look online to find install instructions for your OS)
- Arduino (modern version)
- Teensyduino + Installer
- MP4 to bin video converter (in my git repo)
- Alarm clock code (in my git repo)
- Test video, no audio (in my git repo)
- Test video, audio (in my git repo)
Files (attached as ZIP):
- Original MP4 video
- BIN video
Step 2: Test Video on Your Teensy (Without Audio)
(Assuming you have installed the latest version of Arduino and Teensduino on your machine)
Build the circuit as shown in the image:
PWR – Connect to Teensy3.6 3-5V
GND – Connect to Teensy3.6 Ground
CLK – Connect to Teensy3.6 pin 14
MISO – Connect to Teensy3.6 pin 39
MOSI – Connect to Teensy3.6 pin 28
CS – Connect to Teensy3.6 pin 21
D/C – Connect to Teensy3.6 pin 20
RST – Connect to Teensy3.6 3-5V (send to ground if you want to reset)
ZIP of video files is attached. Grab the file "wake_up_wake_up.bin" and put on micro SD. Put this micro SD in the slot on the Teensy3.
Grab the Arduino code "arduino_testvideo_noaudio.ino". Upload to Teensy3. Ensure your settings match that in the image. If you have just unboxed the Teensy it takes a bit of wrestling to get the first sketch on. Check out pjrc.com for help with that.
If the video plays then all is good!
Step 3: Test Video on Your Teensy (With Audio)
Add a speaker and amp to your circuit as shown in the images. Use pins A21 and GND on the Teensy3.6.
Open the file "arduino_testvideo_audio.ino" in Arduino.
Note that compiling, a bunch of errors may be thrown because we are using SdFat.h instead of SD.h
If this happens follow the steps here: https://youtu.be/5FqCr4TGehw?t=9m40s to comment out parts of code. Once you do this properly everything should compile.
If you want hifi audio, you will have to add the Teensy Audio Board. And if you want it really loud you will have to add bigger amp/speaker.
Note that the volume of my video file is quite low because I didn't want to have a heart attack when I wake up. It can easily be increased by editing the volume of the original MP4 and exporting a new BIN.
Another thing you can try is the I2S mono amplifier from adafruit. Should give you some more audio versatility, if needed.
Step 4: Preparing a Custom .BIN Video
ILI9341 is at 320x240 resolution. Your video needs to match. I exported H.264 MP4 from Premiere @ 320x240 @ 23.976fps. If you want the audio loud, turn up the gain, as there is no way that I know of to adjust audio volume from the Teensy over DAC.
Teensy3 cannot play any encoded media. It can only play binary! Thankfully Frank (https://github.com/FrankBoesing) wrote us a slick little Processing application to convert MP4 to BIN.
We need to export just the audio from this MP4. We can do that with ffmpeg. Open the command line and run this command on the MP4: "ffmpeg -i "yourvideo.mp4" -f s16le -ar 44100 -acodec pcm_s16le output.raw"
Get the latest version of Processing. Now open "mp4_to_bin_processing_pde.pde" in processing from the github. Edit the lines of code corresponding to your files. Hit run. This should export a .BIN for your video. Note that if you interact with the software it will sometimes mess up (not sure why). Best just leave it alone. At the end of the video you must press the stop button in Processing and it will export the entire file. Files are ~200MB/min in .BIN so if your exported file is small, then something went wrong.
*** Note, I kept getting an error thrown from processing that said "error, disabling movieEvent() for processing". If you get this error then the export will not work. I could not figure out the cause of the error but noticed it only happened with longer videos. ***
Step 5: Testing Your Custom Video
Add your .BIN video to the SD card. Update "arduino_testvideo_audio.ino" to use your video.
I had it play with wacky audio a few times at alternative frame rates. Maybe the frame rate 23.976 works best?
Step 6: Build Your Enclosure
My laser cutting files are attached.
- 1/4" matte black acrylic for feet
- 1/8" matte black acrylic for body
- 1/16" black acrylic for display border
Follow the images to build my enclosure. Note, super glue was used ;)
It was my first prototype for the enclosure. I am sure you can come up with a slicker design.
Step 7: Add the Clock Interface
For my interface I used:
- Three way switch: Set Time | Set Alarm | Run
- Encoders for hours and minutes.
- Toggle for alarm on/off.
Connect hour encoder to pins 2 and 3. Remember to connect the middle to GND.
Connect minute encoder to pins 4 and 5. Remember to connect the middle to GND.
Connect three way switch to 7, and 8. And GND for input_pullup.
Connect alarm toggle to 6. And GND for input_pullup.
Step 8: Testing the Circuit
Now all the parts of your circuit should be complete.
Test the circuit with the final code: https://github.com/FuzzyWobble/video-alarm-clock-teensy/tree/master/arduino_video_alarm_clock_teensy
Make sure everything is working before putting it inside the enclosure.
Lots of comments in the code to help you!
Step 9: Get It All Inside
Like all good DIY electronics project, it is a mess of wires inside.
I thought I would have lots of free space with this enclosure design but turns out it took a bit of tetris to fit it together.
Note the power cable added through the hole with a stress relief (knot).
Step 10: Success!
You have just built a video alarm clock with Teensy! You are a genus!
Second Prize in the
Audio Contest 2017