SPI – Sample of master and slave using two Arduino

Sample of SPI communication using two Arduino on S4A Programming Learning Board :

Arduino’s SPI master code (mirror)

Arduino’s SPI slave code (mirror)

How it works:

When at master board is pressed button attached at pin 2 (zero level), it is immediately received by slave and lits led at pin 3 on. Afterwards, master is reading slave and updates its led at pin 3. Pressing again button at pin 2 at master side lits led at pin3 off at slave side and, afterwards, master updates its own pin 3.