From d1cb582de8efadfa0ca4a26e872d813f6d5a1571 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Sat, 5 Mar 2011 22:43:57 +0000 Subject: [PATCH] rf433rcv serial sender and reciever --- rf433rcv/pc.cpp | 36 ++++++++++++++++++++++++++++++++++++ rf433rcv/rf433rcv.pde | 14 +++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 rf433rcv/pc.cpp diff --git a/rf433rcv/pc.cpp b/rf433rcv/pc.cpp new file mode 100644 index 0000000..53ef05a --- /dev/null +++ b/rf433rcv/pc.cpp @@ -0,0 +1,36 @@ +#include + +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; + } + } +} diff --git a/rf433rcv/rf433rcv.pde b/rf433rcv/rf433rcv.pde index 8b44f74..fa4afbb 100644 --- a/rf433rcv/rf433rcv.pde +++ b/rf433rcv/rf433rcv.pde @@ -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(); } -- 1.7.10.4