diff options
| author | Abel Tim <abel@main.home> | 2024-06-02 17:57:32 +0200 |
|---|---|---|
| committer | Abel Tim <abel@main.home> | 2024-06-02 17:57:32 +0200 |
| commit | 6671a64563369d8e3540639753ba64086a75d7a3 (patch) | |
| tree | 7bb8a4dc198773c517ac2148e7e051be1f76aaba /spi_comm/arduino_slave_write/arduino_slave_write.ino | |
| parent | b6bdab63c9902604a74a7b4b996bdd0dc7614454 (diff) | |
| download | robotica-6671a64563369d8e3540639753ba64086a75d7a3.tar.gz robotica-6671a64563369d8e3540639753ba64086a75d7a3.zip | |
add files
Diffstat (limited to 'spi_comm/arduino_slave_write/arduino_slave_write.ino')
| -rw-r--r-- | spi_comm/arduino_slave_write/arduino_slave_write.ino | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spi_comm/arduino_slave_write/arduino_slave_write.ino b/spi_comm/arduino_slave_write/arduino_slave_write.ino new file mode 100644 index 0000000..d6f838f --- /dev/null +++ b/spi_comm/arduino_slave_write/arduino_slave_write.ino @@ -0,0 +1,34 @@ +#include <SPI.h> + +int x; +long randNumber; + + +volatile boolean received; +volatile byte Slavereceived,Slavesend; + +void setup() { + Serial.begin(115200); + randomSeed(analogRead(0)); + + pinMode(MISO,OUTPUT); + SPCR |= _BV(SPE); + received = false; + SPI.attachInterrupt(); + +} + +ISR (SPI_STC_vect){ + Slavereceived = SPDR; + received = true; +} + +void loop() { + // put your main code here, to run repeatedly: + randNumber = random(0, 1); + Serial.println(randNumber); + Slavesend=randNumber; + SPDR = Slavesend; + delay(1000); + +} |
