Skip to content

Instantly share code, notes, and snippets.

@teddokano
Created June 28, 2023 07:38
Show Gist options
  • Save teddokano/c199f3a62b5868f9149a98fee72cea97 to your computer and use it in GitHub Desktop.
Save teddokano/c199f3a62b5868f9149a98fee72cea97 to your computer and use it in GitHub Desktop.
SPI test code for Arduino UNO R4
#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