Pin connection

Hii,

I am using adxl345 and Arduino mega 2560. i want to use the SPI connection. what should be the pin connection for that if anyone can help me. i have connected like this

VCC - 5V
GND - GND
SDA - 20
SCL - 21
CS - 19
SDO - 22

VCC - 5V

The chip pin is called Vs. As you have a Vcc pin I guess you don't use the chip but some breakout board. But you failed to provide a link to it.

I recommend to use the ICSP header to connect the SPI pins as this is the preferred method for shields too.

if you could elaborate it would be beneficial

SPI uses the SCK, MOSI, MISO and CS (or SS) pins. Those pins are 52, 51, 50 and 53 (defalut) on a Mega. Those pins are also available on the ICSP connector.

shahpurvin8:
Hii,

I am using adxl345 and Arduino mega 2560. i want to use the SPI connection. what should be the pin connection for that if anyone can help me. i have connected like this

VCC - 5V
GND - GND
SDA - 20
SCL - 21
CS - 19
SDO - 22

Those aren't the SPI pins on the Mega. 50/51/52/53 are the SPI pins.

SDA and SCL are nothing to do with SPI, those are I2C pins. SPI is MISO/MOSI/SLK/CS

OP is on a 7 day holiday until he READS THIS.

Bob.

MISO should be connected to MOSI and vice versa..

Not true.

See here:
https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all
and

jackrobot:
MISO should be connected to MOSI and vice versa..

If you understood what those acronyms stand for, you wouldn't make that mistake. If you checked your facts before posting that would be good too.