Welcome to another blog post! NOTE: This post details my work on a completely separate project to my robot - work is progressing but I haven't done enough for it to qualify for a blog post just yet. ALSO: The videos included in my project are just test files.
Recently, I was asked to design an automated video player for a local LEGO store - an exciting first paid project for an actual company! The brief was simple. The store owner needed a cheap and reliable standalone replacement for his PC setup which plays themed videos on the press of a button. The task can be broken down into a number of required objectives:
Be cheap and perform well enough for the PC to become redundant.
Play background music on a loop until the pi reads an input.
Once the pi reads input from a button press, play a video - blocking all button presses while playing.
After the video has played, return to playing the looping background music.
Work on boot
I think the pi fits the needs of the store owner well so I decided to pursue the project using a raspberry pi 3B. I first set out creating a parts list which I would need to acquire in order to make the finished product before I set out making a prototype. Here is the parts list below: (All parts are being bought from pimoroni)
Raspberry Pi 3B+ - £32 (The Brains of the operation)
100mm Arcade Button - £8.70 (Used to trigger the video changes)
Power Supply (If you don't already have one)
Micro SD Card (Needed for the Pi's OS - you can read how to set it up here)
Heatsink - £1 (Optional)
After modifying the code my neighbour had kindly volunteered to help me with I made the suitable GPIO connections from the button to the pi according to my code. (You may need to use a resistor) As you may be able to tell from the video, my connections aren't the neatest but I will update you in a later blog post once I receive the parts.
The Code:
Here is a look at a version of my code which controls the playing of the videos. The python script plays the background music loop by utilising a Popen call to OMXPlayer which actually plays the video. The button presses are detected using interrupts -when this is triggered it calls the videoStatus() function which plays the second video using an os.system() call which blocks the program. This is useful because it helps to block button presses so that customers cannot accidentally trigger a restart of the performance mid-way. After the video has finished playing it calls the video background function which goes back to the original video.
What I need help with?
If anyone knows how to stop the flash of code and the terminal between playing videos please contact me as I have no idea of how to solve this issue.
Thanks for Reading!
コメント