Pins A6/A7/Ax.. vs I2C (for accelerometer addition)

Hey guys-

I am trying to plan out (on paper for now) a new project that will require an accelerometer..

The board I will be using.. and re-designing to add in an accelerometer is more or less..

an Arduino and Adafruit Waveshield merged into an all-in-one board..

Here is my custom board shown against an Uno with Waveshield stacked on top:

This is my 'go to' board for my prop projects.. (when I need audio)... and so far has server me great.

I have always wanted to re-design it.. and add a few more features to it..

in this case, I had always kicked around the idea of breaking out pins A6/A7 and using one of the currently broken out Ax pins.. to read/connect to a analog accelerometer...

I havent looked into this too much.. but from what I gather/understand.. the A6/A7 pins can ONLY be used as input pins.. correct?

(so I'm still ok to use them with an analog based accelerometer.......yes?)

I see the ADXL345 accelerometer is a pretty popular accelerometer to use as well...

however this is an I2C based chip... (which I have never worked with before)..

The board will playing audio.. and controlling other components.. (leds...or possibly some servos..etc)..

My question.. or more so,.. looking to get some shared experiences..

On what would be the best route here?

or an Analog based accelerometer with pins A6, A7 & Ax connected to it?

Anyone foresee any problems with going with either? While the 'waveshield' is playing audio? (interrupt based from what I gather, Timer1)

  • Timer 2 is often used to work with connected servos (SeroTimer2 library)

Looking for some discussion on this topic.. pros/cons.. things I may be overlooking or not know about that others with this experience can share?

Going out of town for a week or so.. and want to discuss, and have a plan of action for when I return.

For an ATmega328P, the A6 and A7 are analog input only. The digital part (digital input and output) is missing for those pins.
Why not use a digital accelerometer ?

@Koepel -

Well since those pins arent being used for anything… I figured… why not break them out… use for this application, and not really take away any more I/O’s on the board for other uses…

*(I know I still need to take one of the currently available analog pins for this as well… but better to remove 1… then remove 3)

Maybe I am using the wrong terminology here? (sorry)…

What does a ‘digital’ accelerometer do? How does the data get returned to be used in the sketch?

I have an accelerometer (cant recall the brand/model)… but has 3 outputs…

X, Y, Z… that connect to analog pins… and gives me a 0-1023 ‘response’ depedning on the force/G’s applied to the chip.

Its from here:
(but I dont recall the model/version for now…just remember how it works… ie: analog value output/data)

I also have a breakout board for an ADXL345 accelerometer chip… (havent used this before… or played with I2C ever before to be honest)

I’m trying to weight the pros and cons (or anything I might not know about or have overlooked)… of using either type…

I’m trying to keep the custom board with as many I/O as possible… so it can be used in multiple applications
(its kind of my generic platform board)

Current has audio capabilities (DAC, AMP)
microSD card for housing audio files or text files or just for regular ‘logging’.

its been missing an accelerometer for a long time… and am looking into the best way to accomplish this.

*(I’d also like to work some sort of hi-powered led driver too!)… ← but thats for a later date I guess :slight_smile:

A digital accelerometer uses the I2C bus instead of giving you three analog outputs - which you then have to digitise.

Thus you only need to connect it to A4 and A5 along with all your other I2C devices and the code is substantially simpler.

It makes virtually no sense to use an analog accelerometer with an Arduino. I'm not sure what they are useful for at all.

The common ADXL345 is good. It is a digital sensor, I mean the sensor itself is analog but it has a digital interface to the microcontroller. That is often I2C, but sometimes the SPI bus or something else.
If you want to filter the data, then you can add a RC filter to an analog sensor, but you have to do it in software for a digital sensor.

An analog input can be used for : measure battery voltage; LDR for the amount of light; soil humidity with two metal pins; voltage and current; piezo knock "sensor"; and so on.

I wanted to use spare analog inputs for one of my projects, and I have added a LDR and a ACS712 to measure the current (before the DC-DC converter) of the project itself, and a few voltages as well.


so ADXL345 it is! :slight_smile:

I suppose, then I dont need to break out any more pins... (just leave the original A4/A5 pins broken out)..

and find a place (space) to add it to my board somewhere...

dumb/generic question about I2C bus.

  • I understand you can have multiple devices on the I2C bus, and each one has/is given an 'address'...

is there anything hardware wise that needs to be done to each device connected to the I2C bus/lines?

just follow the schematics for said component/device?

I have a breakout board with the ADXL345 on it.... so I can do some standalone projects/testing with it to come to terms with I2C in general.. and also how the data from the accelerometer needs to be parsed..etc

  • any problems/issues with using I2C stuff, along with playing audio? (Waveshield/WaveHC lib)
    like do any of the libraries that allow for I2C communication.. (Wire library?)

thank you for the discussion/feedback guys. you have helped choose a path in the project. (barring any issues with Timers/Audio playback..etc)

Every I2C device has an address. The Arduino (I2C Master) writes an address to the I2C bus and if a device (I2C Slave) recognizes its own address, then it responds with an acknowledge. After that, the Master can communicate with the Slave.

The trouble is when two devices have the same address, that is not possible. There are many ways to solve that though.

The Wire library uses the SDA and SCL pins, which are A4 and A5 for an ATmega328P. It does not use a timer or other pins or other hardware.

Many Arduino boards still run at 5V, and most sensors with I2C run at 3.3V. There are situation that they can be connected, but that will be outside the specifications and not reliable. A level shifter is able to connect a 5V I2C bus to a 3.3V I2C bus.


thanks guys.

I'll be using the ADXL345 for the updated version of the board!