summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Traut <manut@mecka.net>2012-07-21 16:10:44 +0200
committerManuel Traut <manut@mecka.net>2012-07-21 16:10:44 +0200
commit4590d60345fb5a3891c3894a1dec098f835395f1 (patch)
tree3cec350da1e04fec7e925e8757bf463175668e4e
parent55c3682837e9f525caff885592c101a949def947 (diff)
fix some minor bugs - works now to toggle one LEDhuhu
Signed-off-by: Manuel Traut <manut@mecka.net>
-rw-r--r--Blinkme_spi.ino38
1 files changed, 14 insertions, 24 deletions
diff --git a/Blinkme_spi.ino b/Blinkme_spi.ino
index 44ae27d..3943fe3 100644
--- a/Blinkme_spi.ino
+++ b/Blinkme_spi.ino
@@ -1,11 +1,8 @@
-
-
-
#include <SPI.h>
// * CS - to digital pin 10 (SS pin)
// * SDI - to digital pin 11 (MOSI pin)
-// * SDI - to digitak pin 12 (MISO pin)
+// * SDI - to digital pin 12 (MISO pin)
// * CLK - to digital pin 13 (SCK pin)
// Vorbereitungen um als Slave Daten zu empfangen
@@ -18,10 +15,11 @@ const int slaveSelectPin = 10;
const int miso = 12;
const int mosi = 11;
+const int ledPin = 2;
void setup() {
- Serial.begin (115200); // debugging
+
pinMode(slaveSelectPin, INPUT);
pinMode(miso, OUTPUT);
@@ -34,16 +32,11 @@ void setup() {
SPI.attachInterrupt();
// initialize the digital pin as an output.
- pinMode(0, OUTPUT);
- pinMode(1, OUTPUT);
- pinMode(2, OUTPUT);
- pinMode(3, OUTPUT);
-
- // ... und so weiter
+ pinMode(ledPin, OUTPUT);
-
- // Initialize SPI
- // SPI.begin();
+ digitalWrite (ledPin, HIGH);
+ delay(1000);
+ digitalWrite (ledPin, LOW);
}
//PINS/Bitmask fuer LEDs
@@ -61,10 +54,7 @@ ISR (SPI_STC_vect)
if (pos < sizeof recieve_buff)
{
recieve_buff[pos++] = c;
- if (c == '\n')
- {
- process_it = true;
- }
+ process_it = true;
}
}
@@ -75,13 +65,13 @@ void loop()
//Verarbeitung der empfangenen Nachricht
if (process_it == true)
{
- recieve_buff[pos]=0;
- Serial.println (recieve_buff);
- pos = 0;
+ if (recieve_buff[pos] == 0x31)
+ digitalWrite (ledPin, HIGH);
+ else if (recieve_buff[pos] == 0x30)
+ digitalWrite (ledPin, LOW);
+
process_it == false;
+ pos = 0;
}
-
-Serial.println("huhu");
-
}