Created
May 19, 2018 06:38
-
-
Save iotguider/e3225f6ad68fb99b254d1bcd93c10d8b to your computer and use it in GitHub Desktop.
Code for Master Arduino for SPI Communication
This file contains hidden or 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 <SPI.h> | |
void setup() { | |
Serial.begin(115200); //set baud rate to 115200 for usart | |
digitalWrite(SS, HIGH); // disable Slave Select | |
SPI.begin(); | |
SPI.setClockDivider(SPI_CLOCK_DIV8);//divide the clock by 8 | |
} | |
void loop() { | |
char c; | |
digitalWrite(SS, LOW); // enable Slave Select | |
// send test string | |
for (const char * p = "Hello, world!\r" ; c = *p; p++) { | |
SPI.transfer (c); | |
Serial.print(c); | |
} | |
digitalWrite(SS, HIGH); // disable Slave Select | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment