If you follow me on Twitter or Instagram, or if you have been to my talk at LaraconEU, you might have seen this project before. It’s a fun project I’ve initially built to reuse an Arduino-based board I had here (a Diavolino board, to be precise) with an LED display shield called “LOLShield” – that’s why I ended up calling this project “LOLBox”. This is a first iteration, there’s a lot to improve, but I wanted to share what I’ve done so far.
In this post I’ll share how I created the first prototype, the parts I used and the code I’ve written to make everything work. Even though some parts might be very specific (like the LED shield I used), you can use this as a base to create a project with a similar structure.
This project uses serial communication to send commands to the Arduino board via USB, using PHP code. This way, there’s enough freedom to develop applications at a higher programming level, while the low-level stuff keeps being handled by Arduino using default libraries available for components and shields.
This is a little demo showing how it works:
New demo 🤓 Arduino + LOLShield controlled by a @LaravelZero app 😉 super fun! pic.twitter.com/QaDii5zA9x — codingmama.labs (@erikaheidi) August 14, 2018
The Arduino code listens for data coming from the serial. The board must be connected to a computer that will execute the PHP code from the command line; this code will send data to feed the Arduino device.
We use a new line (‘\n’) as delimiter, otherwise we couldn’t know for sure when the message ends. In this specific project, I’m sending data as string because I’m sending arbitrary messages to be displayed on the LED display. I wrote a tutorial showing a more basic implementation that works with numbers instead, sending RGB values to light up an LED: How to communicate with an Arduino via Serial using PHP code .
At the PHP side, I’m using a micro framework called Laravel Zero. I’ve implemented a couple different commands to test the display, but my favorite one is the Tweet monitoring – it shows, on rotation, stats about your last tweet (retweets and likes). For this to work, it’s necessary to update the app config settings to include the Twitter application and user tokens.
Diavolino – Arduino based board
LOLShield – Arduino compatible shield
USB to TTL cable (the Diavolino board uses TTL for serial communication)
Enclosure (3D printed)
The enclosure was created on Freecad, it was a great learning exercise, but there’s still some work to do. I was happy with the result from the photo because it was good enough for demo’ing, but I definitely want to improve the enclosure to make it look nicer and to make things fit better. For this 0.1 version, this is basically how it looks:
The main problem at the moment with the enclosure is that the lid holes are not matching the base box screw holes. I might be able to fix it just by tweaking the lid a bit and printing it again.
The little green pcb on the bottom is used to fix a 6-pin header to connect the TTL/USB cable.
The code, along with STL files and Arduino files is all available at this repository: https://gitlab.com/codingmama/lolbox . Needless to say, this is an ongoing project and things might still change a lot.
Questions? Suggestions? Feel free to leave a comment! I will be posting updates as soon as I have them 🙂