Skip to content

Instantly share code, notes, and snippets.

@funvill
Created November 5, 2015 18:21
Show Gist options
  • Save funvill/e1399a0928034671803f to your computer and use it in GitHub Desktop.
Save funvill/e1399a0928034671803f to your computer and use it in GitHub Desktop.
A Arduino sketch to test the SPI library/ports
// include the SPI library:
#include <SPI.h>
#include <inttypes.h>
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// put your setup code here, to run once:
Serial.println("SPI.begin()...");
SPI.begin();
}
void loop() {
// put your main code here, to run repeatedly:
SPI.beginTransaction( SPISettings(14000000, MSBFIRST, SPI_MODE0) );
for( int outByte = 0 ; outByte < 10 ; outByte++ ) {
byte inByte = SPI.transfer( outByte);
Serial.println("inByte=" + String( inByte ) + " outByte=" + String( outByte ) ) ;
}
SPI.endTransaction();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment