Compiling error exit code 1

Usually this means you're accessing out of array bounds.

 error: 'SPI' was not declared in this scope

You need the SPI library.

Please remember to use code tags when posting code.