Created
November 5, 2015 18:21
-
-
Save funvill/e1399a0928034671803f to your computer and use it in GitHub Desktop.
A Arduino sketch to test the SPI library/ports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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