stoppuhr s

Dependencies:   PinDetect TextLCD mbed

Fork of FeuerwehrStoppuhr0805 by Jovica D.

Revision:
3:6f6ee868bf8c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HM-TRP.h	Wed May 08 13:59:35 2013 +0000
@@ -0,0 +1,48 @@
+//send data routine
+ 
+// link between the computer and the SoftSerial Shield
+//at 9600 bps 8-N-1
+//Computer is connected to Hardware UART
+//SoftSerial Shield is connected to the Software UART:D2&D3 
+ 
+#include <SoftwareSerial.h>
+ 
+SoftwareSerial SoftSerial(11, 10); // TX, RX
+int buffer[64];
+int count=0;
+void setup()  
+{
+  SoftSerial.begin(9600);               // the SoftSerial baud rate   
+  Serial.begin(9600);             // the Serial port of Arduino baud rate.
+ 
+}
+ 
+void loop()
+{
+  delay(1000);
+  SoftSerial.write(0xAA);
+  SoftSerial.write(0xFA);
+  SoftSerial.write(0xE1);
+ 
+  if (SoftSerial.available())              // if date is comming from softwareserial port ==> data is comming from SoftSerial shield
+  {
+    while(SoftSerial.available())          // reading data into char array 
+    {
+      buffer[count++]=SoftSerial.read();     // writing data into array
+      if(count == 64)break;
+    }
+    for (int i=0; i<count; i++) {
+      Serial.print(buffer[i],HEX);            // if no data transmission ends, write buffer to hardware serial port
+    }
+    clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array
+    count = 0;                       // set counter of while loop to zero
+  }
+  if (Serial.available())            // if data is available on hardwareserial port ==> data is comming from PC or notebook
+    SoftSerial.write(Serial.read());       // write it to the SoftSerial shield
+  Serial.println("...");
+}
+void clearBufferArray()              // function to clear buffer array
+{
+  for (int i=0; i<count;i++)
+    { buffer[i]=NULL;}                  // clear all index of array with command NULL
+}
\ No newline at end of file