Question.3
What number will be printed on Arduino2’s and Arduino3’s serial monitor? (after executing the following code)
Arduino1 (master) code:
#include <SPI.h>
void setup() {
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV8);
delay(2000);
}
void loop() {
digitalWrite(SS, LOW);
SPI.transfer(9);
digitalWrite(SS, HIGH);
while (1);
}
Arduino2 and Arduino 3 (slave’s) code:
#include <SPI.h>
uint32_t count = 0;
uint32_t start_ms = 0;
void setup() {
Serial.begin(115200);
pinMode(MISO, OUTPUT);
SPCR |= _BV(SPE);
pinMode(SS, INPUT_PULLUP);
SPI.attachInterrupt();
start_ms = millis();
}
void loop() {
}
ISR(SPI_STC_vect) {
Serial.println(SPDR);
}