diff options
Diffstat (limited to 'Blinkme_spi.ino')
| -rw-r--r-- | Blinkme_spi.ino | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/Blinkme_spi.ino b/Blinkme_spi.ino deleted file mode 100644 index 3943fe3..0000000 --- a/Blinkme_spi.ino +++ /dev/null @@ -1,77 +0,0 @@ -#include <SPI.h> - -// * CS - to digital pin 10 (SS pin) -// * SDI - to digital pin 11 (MOSI pin) -// * SDI - to digital pin 12 (MISO pin) -// * CLK - to digital pin 13 (SCK pin) - -// Vorbereitungen um als Slave Daten zu empfangen -char recieve_buff [100]; -volatile byte pos; -volatile boolean process_it; - -// PINS fuer SPI -const int slaveSelectPin = 10; -const int miso = 12; -const int mosi = 11; - -const int ledPin = 2; - - -void setup() { - - pinMode(slaveSelectPin, INPUT); - pinMode(miso, OUTPUT); - - // SPI als Slave aktivieren - SPCR |= _BV(SPE); - - // interrupt vorbereitung - pos =0; //recieve Buffer leer - process_it = false; - SPI.attachInterrupt(); - - // initialize the digital pin as an output. - pinMode(ledPin, OUTPUT); - - digitalWrite (ledPin, HIGH); - delay(1000); - digitalWrite (ledPin, LOW); -} - -//PINS/Bitmask fuer LEDs -int LED0 = 0x01; -int LED1 = 0x02; -int LED2 = 0x04; -int LED3 = 0x08; - -int PWM_BASE = 15; - - -ISR (SPI_STC_vect) -{ - byte c = SPDR; - if (pos < sizeof recieve_buff) - { - recieve_buff[pos++] = c; - process_it = true; - } -} - - -void loop() -{ - - //Verarbeitung der empfangenen Nachricht - if (process_it == true) - { - if (recieve_buff[pos] == 0x31) - digitalWrite (ledPin, HIGH); - else if (recieve_buff[pos] == 0x30) - digitalWrite (ledPin, LOW); - - process_it == false; - pos = 0; - } -} - |
