Raspberry Pi Gpio as a ATmega382 (arduino chip) programmer.

In this post, I will outline how to connect a barebone ATmega382 IC (the brains of an arduino UNO) to a raspberry pi using the GPIO pins.

Needed parts:

  • This barebones arduino kit (from iprototype.be) : 7,45 € (includes a socket, a 16 Mhz Crystal, some capacitors, some resistors and a LED (which I accidentaly blew :s)) (build instructions can be found here: http://arduino.cc/en/Main/Standalone. The only difference here is that we don’t need the FTDI-usb-breakout board (which costs 14.95$) (This role is taken over by the raspberry pi). This is powered by a 9V battery.
  • A Logic Level Converter: bought this one from ebay (4,5€). (sparkfun also sells one). You will need one with at least 4 channels. This converts the gpio levels from 5v (arduino) to 3.3 v (raspberry pi), since the pi’s pins aren’t protected and 5v can destroy the pi. Remember to connect the ground of the Pi to the ground of the Arduino (this stopped me in my tracks for a while)
  • I also had an Adafruit Pi T-Cobbler and two breadboards.

Mainly I followed this guide: http://www.deanmao.com/2012/08/06/arduino-and-the-raspberry-pi/

The settings made on the raspberry pi (commenting out all the /dev/ttyAMA0) are important, or it won’t connect serially.

BTW: You can monitor the serial output of the arduino by typing “screen /dev/ttyAMA0”. The only thing is that the upload fails when there is traffic on the serial output of the arduino. It only works after a reset of the arduino.

The other main part is to never ever connect the Raspberry Pi directly to the arduino(-chip), or the Pi can be blown up. That’s where the Logic Level Converter comes in.

The connections to be made (All Trough the Logic Level Converter):

Arduino, Raspberry Pi

D0 (Rx), Tx
D1 (Tx), Rx
RST, Gpio #24
Vcc, 3.3 V

Be Sure to also connect the Ground of the pi directly to the ground of the Arduino, or it won't work!
The RST (reset) to Gpio 24 serves to reset the arduino right before uploading the sketch.
Raspberry pi acting as an arduino sketch uploader to a barebone ATmega382 IC.
Raspberry pi acting as an arduino sketch uploader (to the left) to a barebone ATmega382 IC.(right)

The setup here is an arduino connected to a potentiometer on pin A0 and a LED on pin D9 (PWM).

When you turn the potmeter, the LED goes brighter or less bright, and eventually completely off.

[sourcecode language=”cpp”]</span></span>


const int buttonPin = 2
int led = 9; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
pinMode(buttonPin, INPUT);

// the loop routine runs over and over again forever:
void loop() {
// read the potmeter on A0
int sensorValue = analogRead(A0);

// read the state of the button:
buttonstate = digitalread(buttonPin);

// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the loop:
//brightness = half of the potoutput;
brightness = sensorValue/4;

if (buttonState == HIGH) {
else {