arduino:gammon-spi-controller
This is an old revision of the document!
Written by Nick Gammon February 2011 With Mithat Mods – July 2023 #include <SPI.h> void setup (void) { digitalWrite(SS, HIGH); ensure SS stays high for now
// Put SCK, MOSI, SS pins into output mode // also put SCK, MOSI into LOW state, and SS into HIGH state. // Then put SPI hardware into Master mode and turn SPI on SPI.begin ();
// Slow down the master a bit
SPI.setClockDivider(SPI_CLOCK_DIV8); mithat: let's go full speed
} end of setup void loop (void) { char c; enable Slave Select
digitalWrite(SS, LOW); // SS is pin 10
// send test string for (const char * p = "Hello, world!\n" ; c = *p; p++) { SPI.transfer (c); delayMicroseconds(5); // mithat: added small delay to make things work at full speed }
// disable Slave Select digitalWrite(SS, HIGH);
delay (1000); // 1 seconds delay
} end of loop </file>
arduino/gammon-spi-controller.1690220589.txt.gz · Last modified: 2023/07/24 17:43 by mithat