So I got myself an Arduino powered Android Accessory Development Kit, not long ago. The kit have quite a lot of sensor, one of them, an 125kHz RFID reader. Which is cool except, the kit doesn’t comes with the tag necessary.
I have started a series of post on making robots with arduino at hackerspacekl website. You can find out more on the links :
Not long ago, Me and the Hackerspacekl gang, join The Global Hackerspace Challenge. Basically we build a Arduino Shield that process words.
Actually the whole process is best viewed on the hackerspacekl blog.
In summary, here is what we learned.
– K.I.S.S, Keep It Small and Simple
The Atmega168 have only 16KiB of memory which the code itself taken half of it. and it is slow, it runs on such a speed 16 MHz. Modern computer is around 2 GHz. It better be simple, because debugging is hard.
– Serial is your best friend (on arduino anyway)
Unlike programming on PC or Web app. There is no print function to be used to debug, there is no debugger either. Even we have a LCD, it is not reliable. And serial pretty much built into the arduino board. So USE IT.
– Optimization matters
On dynamic language like python, or more modern language like java. There is garbage collector, even c/c++ have OS to help on that. So one don’t need to worry about memory issues. But on arduino, removing unused code and code, and save a lot of memory.
– One need to think very low level.
The I2C to eeprom code is about shifting bits/bytes to write to the EEPROM. For once we are thinking in bytes. And we need to know a bit of hardware, to write the code properly.
Overall, it is fun and a interesting experience. For a programmer that spend time on python, or doing web development. Opening one eyes to embedded programming a bit, a little bit of experience that meant a lot to me.
Yesterday I show a code where when we send a ‘t’ via serial connection, the LED will blink while the arduino board, send back a series of string via serial, the code below is what I used to run on arduino, to test with the python code.
In the arduino development environment, there is a serial monitor that do the the testing.
Since it is just a standard serial interface, so one can just do it anyway they want. Here I show how to do it via python. First what we need, is the pyserial library, you can install it using pip or easy_install or grab it from pyserial site
To install, just use to following command. if you need more detail, read the docs, because I use python 2.7 it just works for me,
To use it, with the arduino code from the top of the page just, do the following
The line s=serial.Serial(2) points to com3 on windows, on linux it should be s=serial.Serial(‘/dev/ttyUSB0’), or other port that shown by the arduino serial monitor. Pyserial actually have a few options on the Serial object, but I found that for arduino, the default is adequate.
And this is how to use arduino to interface to your computer using python. enjiy
So one of the side effect of hanging around with hackerspacekl too much is, one begin to develop feeling toward hacking hardware… Which in one of my post shows their project creating their own arduino severino.
I got myself freeduino thanks to Kakeman, our resident hardware guru in hackerspacekl. It is not the latest, but it is good enough. After following the tutorial, I begin to feel to blink a LED, which built into the board
Then I play around with the serial library,
In the end of the day it is fun, much before I continue, I need to find time to get a breadboard and more components, like LED,transistors, resistors etc, to make more stuff. Think i am going to play with this for a long time to come
So today I go to hackerspacekl which is a awesome place. One of their project now involving arduino. And they making their own. For the rest, I allow the pictures to do the talking. Check the links too