Arduino UnoA common solution is to attach another micro-controller board such an Arduino. The Arduino is a versatile micro-controller that comes in a variety of sizes and packages with "Shields" for advanced expansion. The most common version is the Arduino Uno (pictured below).
To connect the Arduino Uno, using a USB cable (USB type B to A cable) I connected it to a powered USB hub. Then I connected the USB hub to my Raspberry Pi. If your power adapter is sufficient amperage, you should be able to connect the Arduino directly to the Raspberry Pi. I will have several other USB device attached, so the USB powered hub works best for me.
Arduino IDENow that the Arduino is attached to the Raspberry Pi, we can program the Arduino using the Arduino IDE. This can be installed as easy as:
# sudo apt-get install arduino
And then running the Arduino IDE, from within a Windows Manager, with:
Arduino Getting Started (Blink)The Arduino Getting Started Guide has excellent instructions for getting started with the Arduino.
As the Arduino Uno is the "default" for the Arduino IDE, we do not need to make any changes to the IDE to be able to upload our program (Arduino calls the programs Sketches) to Arduino.
From the template Sketches, select the "Blink" example. This sketch will cause the little LED (labeled "L" on my Arduino Uno) to blink on and off.
Congratulations, you can now program the Arduino from your Raspberry Pi.