Re assigning pins on Mega board running accelerometer

I have been successfully running the Adifruit LIS3DH accelerator on the Arduino MEGA board.
The CS pin is currently pin 5. I need to be able to assign some other pin as CS. How do I do this? I would have thought it sensible to easily be able to find where the pin is defined in the code in some other file. But everything is hidden, this is REALLY REALLY REALLY annoying! Pleas tell me how to assign the CS pin to some other pin. Also the other pins SCL (21) and SDA (20) would also be useful to be able to reassign.


Check the learning centre for a guide for the board. Core copies most of the guides from their suppliers. If they don’t have a guide, Adafruit have an excellent guide on setting up this board, either as SPI or IIC/I2C.

Core’s product description has a link to the guide


Also, wrt the SDA/SCL pins.
The mega has just one hardware IIC/I2C port. Unless you want to write your own library/driver, these pins can’t be changed. Pins 20/21 it is.

The CS pin can be any available digital pin.

Pinouts for the various boards are on the Arduino web site.


Great advice, thanks Robin and good luck Clem!

I agree with Robin. Only the CS pin can be re-assigned.

I knew this coz I had lots of devices attached to my MEGA and had to shuffle out what can be changed and what I had to live with.

Good luck on your project!