3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

I2C Bus for ATtiny and ATmega

Step 4Let's build!

Let\
«
  • ATtiny2313 n Ports.jpg
  • P1020133as.JPG
  • P1020134as.JPG
  • P1020142as.JPG
  • ATmega168s.jpg
  • P1020129as.JPG
  • RAMs.jpg
  • P1020140as.JPG
  • EEPROMs.jpg
  • P1020140bs.JPG
  • last photo ←
»
Start by downloading the file I2C Schematics.zip. You may want to create an I2C folder in your work area to hold the schematics and the example program files. Unzip the schematics into this directory. You'll find a folder called I2C Schematics. Open the file named tiny I2C.pdf. This schematic shows the ATtiny2313 Ghetto Development System, and the PCA8574A I/O Port Expander (has the large dashed box around it). The Port Expander circuit is built on a breadboard. Have a look at the photos to see what these circuits look like. They're really pretty simple.

The ATtiny2313 portion of the schematic is just the Ghetto Development System with three blinkenlights (LED1, 2, and 3, plus R4, 5, and 6) and a pushbutton (S1) hooked to it, plus one additional detail. That detail is the addition of jumpers (JP4, 5, and 6) which can be removed to allow connection of the I2C bus SCL and SDA lines. The jumpers must be in place for programming, then removed so SCL and SDA can be connected. The photos show the jumpers in place and removed. Placement of these jumpers is up to you, you just have to put them on your Ghetto Development System if you want to use the I2C bus. The I2C bus must be disconnected and the jumpers put in place for programming. Note that you only really need to be concerned with JP4 and JP6 for the I2C bus. Put in JP5 if you think you'll ever want to use the SPI bus.

Breadboarding the PCA8574A I/O Port Expander is very simple. Provide Vcc (+5 volts) and Gnd (ground) connections and connect AD0, 1, and 2 to ground (makes the I2C slave address 38 hex). Then connect 4 blinkenlights, and 4 DIP switches. (If you don't have DIP switches you can just use wires. Tie to ground or leave floating to signal on or off respectively.) Finally, connect the pull-up resistors (R11 and 12) from SDA and SCL to Vcc. These are shown as 3.3K, but any value from 1.8K to 5.1K should work (maybe up to 10K but I haven't tried that). Once you've programmed the ATtiny2313 you can remove the jumpers and connect SDA and SCL for testing.

Now for the ATmega168. The only wrinkle here is that you may not have built a Ghetto Development System for this processor. If that's the case, then the schematic I provide (MEGA I2C.pdf) will show you how. This is just a permutation of the ATtiny2313 version. If you plan ahead you can make sure your programming cable will fit both systems. The main difference is the addition of C2 and C3. See the pictures for placement of these, they should be very close to the chip; one of them is actually under the chip. These help keep noise out of the analog to digital converter in particular. You don't need to put in the jumpers unless you plan to use the SPI bus since they're not needed for the I2C bus on this chip. Note that the PCA8754A breadboard will be unchanged. You'll just hook up SDA and SCL and away you go! Easy, huh?
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
41
Followers
8
Author:doctek