rf433rcv serial sender and reciever
authorOthmar Gsenger <otti@realraum.at>
Sat, 5 Mar 2011 22:43:57 +0000 (22:43 +0000)
committerOthmar Gsenger <otti@realraum.at>
Sat, 5 Mar 2011 22:43:57 +0000 (22:43 +0000)
rf433rcv/pc.cpp [new file with mode: 0644]
rf433rcv/rf433rcv.pde

diff --git a/rf433rcv/pc.cpp b/rf433rcv/pc.cpp
new file mode 100644 (file)
index 0000000..53ef05a
--- /dev/null
@@ -0,0 +1,36 @@
+#include <iostream>
+
+int main()
+{
+  unsigned char c =0;
+  unsigned char sym =0;
+  unsigned char old_sym =0;
+  int counter = 0;
+  while( 1)
+  {
+    std::cin >> c;
+    for(int i = 0; i<8; i++)
+    {
+      sym = c & (1<<7);
+      if (sym == old_sym)
+      {      
+             counter++;
+      } else {
+       if (counter > 30 )
+       {
+         std::cout << std::endl;
+       }
+       counter = 0;
+      }
+
+      if( sym)
+      {
+        std::cout << 'X';
+      } else {
+        std::cout << '_';
+      }
+      c<<=1;
+      old_sym=sym;
+    }
+  }
+}
index 8b44f74..fa4afbb 100644 (file)
@@ -115,9 +115,20 @@ void stop_timer() // stop the timer
   TIMSK1 = 0; // disable timer interrupt
 }
 
+byte rf433_data=0;
+byte rf433_cnt=0;
 ISR(TIMER1_COMPA_vect)
 {
-  digitalRead(RF433_PIN);
+  rf433_data<<=1;
+  if (digitalRead(RF433_PIN) == HIGH)
+    rf433_data |=1;
+  rf433_cnt++;
+  if (rf433_cnt>7)
+  {
+    Serial.print(rf433_data);
+    rf433_cnt=0;
+    rf433_data=0;
+  }
 }
 
 //unsigned long wm_start_[3]={0,0,0};
@@ -150,6 +161,7 @@ void setup()
   digitalWrite(RF433_PIN, LOW);  // turn of pullup resistors 
 
   Serial.begin(57600);
+  Serial.println("starting timer");
   start_timer();
 }