Last week I've stumbled upon a great post about Arduino-like device - Pico PiDuino - by Gadgetoid. It is a really minature breadboard Atmel ATmega processor setup, allowing you to explore and learn a bit about the Arduino programming environment. To be honest, to make your own the Pico PiDuino all you need is a small breadboard, ATMega328P-PU with Arduino Bootloader, 16MHz Crystal Oscillator, few jumper wires, LEDs and 220-330 Ohm resistors for the LEDs. As Phil Howard states in his introduction article:
("¦) the Arduino-compatible we're going to build in this tutorial is absolutely, totally, irresponsibly barebones. In a proper breadboard Arduino build you should have a host of capacitors to decouple your power supply, and probably at least some protection circuitry between it and your Pi. If you're at all concerned about blowing up your Pi, read no further! ("¦)
That's very much true, as such a set-up might do some harm to your Pi, e.g. if you mismatch connections. Nevertheless, I've decided to give it a go.
I've bought for this a Gadgetoid recommended Bare Bones Breadboard Arduino Compatible Kit for a reasonable fiver from Phenoptix and started the assembly. Nothing difficult, especially that Phil created a very nice assembly tutorial. Having everything in place, with trembling heart, I've connected the processor to my RasPi. It worked! Nothing blew up, no resets, no lags! It was time for my first Arduino coding, keeping to Phil's tutorial for safety.
Before starting the actual coding, you have to download some additional software to compile and send the data to the chip. You don't have to install Arduino IDE (which, by the way, doesn't want to run on my Pi, don't know why"¦). All you need is an Avrdude library, specially modified by Gordon @ Drogon. All the instructions are on the Gadgetoid's website, I won't, don't want to and don't have to repeat them.
I had some problems with the processor, especially with making it talk to Raspberry using serial connection. I don't know why, even after adding my user to dialout group, after checking the wires for the millionth time, it didn't want to work. I've spent three days, giving up hope, when finally, after talking about it with Phil, it started working. All I had to do was to flash the program onto the processor, pull out and back in the voltage wire and it worked on the spot. I could communicate with the ATMega through my RPi's serial port!
It's really fun and worthwhile even to have a look at this little project. Why? As Phil says:
Because of their [ATMega/Arduino] flexibility and robustness, being able to program a microcontroller is a useful and rewarding skill to have, and it's fortunate that it's possible to leverage your Pi to get started quickly and cheaply with a trusty ATmega 328.
- Learning to program an ATmega, or Arduino, will allow you to build much more specialist control systems which use less power, are much less complex, less prone to failure and more robust than the Pi. These are great for things that the Pi isn't necessary for.
- Once you've grasped the basics and have a project in mind, you can even move on to playing with some of the brilliant official Arduino boards and all the programming skills you pick up will translate right over.
- If you're wanting to produce your own product for sale, you can build your own hardware around an Arduino-compatible ATmega, program your software in the IDE and ship a finished design supporting an ATmega 328p or similar microprocessor.
- It's a fun challenge for a weekend.
Indeed, it is a challenge, a rewarding and great experience, and once you understand how Arduino works, you might even get a "proper" one and try yourself with it. The Pico PiDuino is good for flashing your work onto the processor for sure. To make it do more, you have to add several more components (and you can still keep it on a breadboard). Here are some examples of a full Arduino breadboard:
Have fun, and let me know if you've decided to give Pico PiDuino a try!