Hypriot, wiringPI and a Blinking Light
The nice thing about a Raspberry Pi is the ease on how to control real hardware with it.
Kids in our days have it so easy to tinker with electronics, I wish it would have been that easy in my times. Those twenty years ago when I was tinkering around with resistors and capacitors there were no Arduinos, Rasperry PIs and all those wonderful toys.
In this and this post I have made a Docker host out of a Raspberry PI. It had one container running a web server with a single page.
The next step I took was to “talk” to the input and output pins and make a blinking LED “application” as kind of an “Hello World” example.
There is already an image that we can use for this purpose. It has a tool installed called wiringPI that we will use to turn an LED on and off.
I needed four steps:
- Create the docker-compose.yml that describes my “services”.
- Write a shell script for calling wiringPI to get this LED blinking.
- Getting the Raspberry to start everything after bootup.
- Wire-up the hardware.
The docker-compose file looks like this:
{% gist 20ed411159fc04999c06 docker-compose.yml %}
For actually setting the output mode of the port and letting the LED blink I have created this shell script:
{% gist 20ed411159fc04999c06 blink.sh %}
I have put everything on Github. So, while having logged into hypriot you only need to
git clone https://github.com/twissmueller/docker-pi.git
cd docker-pi
git checkout tags/2015-12-01
For step three the following line needs to be added to /etc/rc.local
:
docker-compose -f /root/docker-pi/docker-compose.yml up -d
Assuming that the all the stuff is in directory /root/docker-pi
.
Now it’s time for some wiring to do. There is a wonderful tool called Fritzing for designing, illustrating and sharing your Raspberry (not only) projects.
You can download the Fritzing project from this link.
Done for today!