LEGEND383
Posts: 9
Joined: Tue Mar 11, 2014 9:01 pm

atmega328 read single gpio pin

Sun Feb 01, 2015 5:14 pm

I'm trying to get some communication between the pi and the atmega328. I've seen all the stuff about setting up a serial connection, but all I'm after is a single digital pin that the pi can set high/low and the atmega can read. Can this be done?

User avatar
DougieLawson
Posts: 33366
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: atmega328 read single gpio pin

Sun Feb 01, 2015 5:18 pm

You can configure an Arduino/Atmega328P as an I2C slave and use the RPi as an I2C master as an alternative to serial.

To do it with GPIO pins you'll need GNDs connected then wire the Arduino/Atmega328P with a 1K/2K resistor voltage divider to ensure you drop the 5V0 from the Atmega down to 3V3 for the RPi. I've never tried it but it should work OK.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
Douglas6
Posts: 4369
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: atmega328 read single gpio pin

Sun Feb 01, 2015 5:45 pm

Done it, it works, but I think I used a 22k/33k ohm voltage divider.

Wait, that was the Pi reading a signal from the Atmega. Going the other way, you won't need a divider, just make sure you never raise the Atmega pin high.

LEGEND383
Posts: 9
Joined: Tue Mar 11, 2014 9:01 pm

Re: atmega328 read single gpio pin

Sun Feb 01, 2015 6:12 pm

Thanks for the replies

Sorry if I wasn't clear, but I'm using the gertduino add-on, and with this board there is no way to physically access the pins.

Guess I'll give the serial connection a go

LEGEND383
Posts: 9
Joined: Tue Mar 11, 2014 9:01 pm

Re: atmega328 read single gpio pin

Sun Feb 01, 2015 6:18 pm

Edit: Sorry for the double post, got a http 500 error when posting the first one

Return to “Add-ons”

Who is online

Users browsing this forum: No registered users and 3 guests