Created
June 28, 2023 07:38
-
-
Save teddokano/c199f3a62b5868f9149a98fee72cea97 to your computer and use it in GitHub Desktop.
SPI test code for Arduino UNO R4
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 <SPI.h> | |
SPISettings spi_setting(1000000, MSBFIRST, SPI_MODE0); | |
void setup() { | |
Serial.begin(9600); | |
while (!Serial) | |
; | |
SPI.begin(); | |
pinMode(10, OUTPUT); // <- this is required to make `digitalWrite(SS, LOW);` work on Arduino R4 Minima. | |
} | |
void loop() { | |
uint8_t data[] = { 0x55, 0xAA, 0x55, 0xAA }; | |
SPI.beginTransaction(spi_setting); | |
digitalWrite(SS, LOW); | |
SPI.transfer(data, sizeof(data)); | |
digitalWrite(SS, HIGH); | |
SPI.endTransaction(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment