I really enjoyed my pebble (too bad caller ID is not working, yet), and i’m very happy to have been one the sponsors of the “rise of the smartwatch” series.
pair this brand new gadget with my interests in home automation, add the release of the pebble sdk, stir it with some juicy python examples, and there you are: a smarthomewatch!
first things first.
to start you need to have a working libpebble setup. i followed the pretty clear readme of this github homepage.
i followed the advice of using the lightblue library as the wrapper around bluetooth stack: looks pretty outdated, but works even on my up-to-date mountain lion powerbook.
if this is your case, before trying to use the libpebble scripts, follow the instructions you can find here. (that’s a fork adapted to run on macos 10.8)
let’s glue them together … and the first smarthomewatch was born! to avoid having to set up a specific application i used the “music” menu, putting my relay list as if it was a playlist, using the play/pause button as a relay toggle.
the code i’m posting is pretty draft, looking more like a hack of the original file, rather than a proper software module. but hey: it works! …
In part 1 of this series, we looked at the basic commands for using software pulse-width modulation (PWM) in RPi.GPIO 0.5.2a and higher. In this article we’ll get a bit more hands-on and into some practical applications for it. It’s all very well being able to make nice square-wave pulses on an oscilloscope, but what’s it actually useful for?
Massive Arcade Button with LED – 100mm Red – OMG WATCH OUT! This 100mm diameter arcade button is so massive and inviting it may collapse upon itself and form a black hole from which not even light can escape! Until it does, however, it ready for all sorts of pressing and pushing. Science has shown no one can resist pressing its shiny surface and saying “beep!”. We’ve seen these on some games of skill in arcades, they’re easy to mount on nearly any kind of enclosure. They’re not waterproof or weatherproof, so best used indoors. (read more)
This is the first in a series of articles which aim to show you how to use this new interrupt facility in Python.
Interrupts are a much more efficient way of handling the “wait for something to happen and react immediately when it does” situation. They free up the resources you would have wasted on polling, so that you can use them for something else. Then, when the event happens, the rest of your program is “interrupted” and your chosen outcome occurs.
If you’re a Minecraft fan and a Pi owner, you’ve probably already downloaded a copy of Minecraft: Pi Edition. But are you getting the most out of the fact that you can modify the world with code in-game?
If you’re not sure where to start, or if you’re looking for ideas (sometimes being given a blank canvas can be lousy for getting the brain sparking), Martin O’Hanlon at the marvellous <Stuff about=”code” /> has several tutorials on Minecraft: Pi Edition, from installing the game to using the Minecraft API to build wonderful things, like magical bridges that appear where’er you walk, games of hide and seek, and in-game analogue clocks.
The hide and seek hack is easy and rewarding: with a little coding you’ll be able to get the game to hide a diamond somewhere in the world for you to find, and to give you hints of the warmer/colder variety.
And we’re all agreed that the clock is just brilliant (it’s also big enough that you can go and stand on the hands). Again, the project has its own page with code and a spot of discussion.
We’d love to see what you’ve been doing in Minecraft – take some video, or write something about your experiments on your own website, and let us know about it!
We have been playing with these for quite a while using Arduinos, and Adafruit’s Arduino library. With that in mind, we structured out library similar to the Arduino library from Adafruit. To help you get up and running quickly, we put together two examples scripts and a readme file featuring an initial draft of the documentation.
One of the reasons that we are so excited about using the LED strips with Raspberry Pis is that they play really nicely with Spacebrew – the LAB’s dynamic routing tookit/service. This is especially true since Adam Mayer developed an awesome python Spacebrew library at our meet-up in January.
Here is a link to the Spacebrew python library repo. Make sure to go through the readme file because you’ll need to install several dependencies to get the Spacebrew library up and running on your device. I’ll post more information about this library sometime in the coming week or two.
Here’s a tutorial how to AVOID bit-banging and use the hardware via C (while still in Python), shared by Louis Thiery in the Adafruit Forums. And here is the code in Github.
This implementation of SPI in Python is hardware based. Linux-level C code is compiled as a Python module. I first learned how to get SPI working on the Raspberry Pi with help from a tutorial by Brian Hensley. However, I love Python and I wanted to use this hardware implementation of SPI from within Python. I little searching told me that what I wanted to do was to “extend” Python with C and so this reference was very helpful.
NEW BOOK – Python for Kids – A Playful Introduction to Programming. Python is a powerful, expressive programming language that’s easy to learn and fun to use! But books about learning to program in Python can be kind of dull, gray, and boring, and that’s no fun for anyone. Featuring original artwork by Miran Lipovača. Full color, over 344 pages.
Python for Kids brings Python to life and brings you (and your parents) into the world of programming. The ever-patient Jason R. Briggs will guide you through the basics as you experiment with unique (and often hilarious) example programs that feature ravenous monsters, secret agents, thieving ravens, and more. New terms are defined; code is colored, dissected, and explained; and quirky, full-color illustrations keep things on the lighter side.
Chapters end with programming puzzles designed to stretch your brain and strengthen your understanding. By the end of the book you’ll have programmed two complete games: a clone of the famous Pong and “Mr. Stick Man Races for the Exit”—a platform game with jumps, animation, and much more.
As you strike out on your programming adventure, you’ll learn how to:
Use fundamental data structures like lists, tuples, and maps
Organize and reuse your code with functions and modules
Use control structures like loops and conditional statements
Draw shapes and patterns with Python’s turtle module
Create games, animations, and other graphical wonders with tkinter
Why should serious adults have all the fun? Python for Kids is your ticket into the amazing world of computer programming.
Multiple Serial Devices in One Terminal, from John Donnal:
My good friend and all around computer genius [Jim] has produced quite a nice terminal program that can host multiple serial devices in a single prompt. Its super easy to use. In hurry? Grab the git repo: https://git.jim.sh/jim/terminal.git. Just add all the devices you want to display as command line arguments and *presto* you have a color coded super prompt.
This is a great tool for debugging multiple devices at once. My latest project involves an EZ430 wireless kit and unfortunately I don’t have the $$ for IAR or CodeWorks. *yet*. So I am forced to use gcc which is cool but the Simpliciti network stack for the EZ430 has to be ported over and there are all sorts of hiccups and bugs that plague this sort of wireless network setup.
Part of working with your Raspberry Pi is learning to code in Python to take advantage of working directly with the device. While the Adafruit WebIDE is one of the easiest way to roll up your sleeves and build from nothing — you may also find for certain projects that you will want to install packages that have great tools and functionality already built-in.
Take some time to check out what is out there; adding in code snippets doesn’t just help you get what you need more quickly, it helps you learn how others have solved the problems you are tackling.
A great tool used for more than just games — also for playing back media and setting up lightweight interactive GUIs.
Pygame is a set of Python modules designed for writing games. Pygame adds functionality on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language. Pygame is highly portable and runs on nearly every platform and operating system. Pygame itself has been downloaded millions of times, and has had millions of visits to its website.
In many ways the go-to package for playing back compressed media in Python, but make sure you prepare for the dependencies and set your expectations for what media can be played back over a $35 computer at an appropriate level.
is a Python module for wav, mp3, ogg, avi, divx, dvd, cdda etc files manipulations. It allows you to parse, demutiplex, multiplex, decode and encode all supported formats. It can be compiled for Windows, Linux and cygwin.
PyMedia was built to be really simple and flexible at the same time. See tutorial for example. It allows you to create your own mutimedia applications in a matter of minutes and adjust it to your needs using other components. Python language is choosen because of simple semantics, complete and reach set of features.
Take a look at the PyCar application which takes advantage of the PyMedia library extensivelly and can turn your PC into the powerful car media center.
I have often heard programmers recommending Zed A Shaw‘s book Learning Python the Hard Way as an excellent way for a novice programmer to build a firm foundation not only in Python, but in coding as a discipline. The “hard” part is the insistence that the student type in all of the exercises by scratch, forcing a little muscle memory, in addition to learning to solve problems as efficiently as possible.
I encourage you to consider picking up the physical book as well, but those who want to check out this resource before buying will be happy to see that the HTML version of the book is free online at the book’s website.
It occurs to me that uniting the Hard Way with the Adafruit Raspberry Pi WedbIDE — the easiest way to learn programming on a Raspberry Pi — might be a killer combination.