spi_documentation_2
Ceci est une ancienne révision du document !
Communication entre Raspberry Pi et Arduino en SPI
Cette page est inspirée de penguintutor.com Using Raspberry Pi and Arduino together through SPI serial communications
# include SPI.h void setup() { // Set the Main in Secondary Out as an output pinMode(MISO, OUTPUT); // turn on SPI as a secondary // Set appropriate bit in SPI Control Register SPCR |= _BV(SPE); } // The following code is then used to receive a byte and then set the data register to return a byte to the master controller device. void loop () { byte in_byte; // SPIF indicates transmission complete (byte received) if ((SPSR & (1 << SPIF)) != 0) { in_byte = SPDR; // Handle the input code here // Set return_val to the value you want to return SPDR = return_val; }
spi_documentation_2.1653916785.txt.gz · Dernière modification : de serge
