Hi all, I'm trying to sample the signal from a RF remote but i'm not really good programming...
I'm using this code:
void setup()
{
pinMode(7, INPUT);
Serial.begin(9600);
}
void loop()
{
unsigned long high;
unsigned long low;
high = pulseIn(7, HIGH);
low = pulseIn(7, LOW);
Serial.print("HIGH: ");
Serial.print(high);
Serial.print(" LOW: ");
Serial.println(low);
}
And I get (with the same botton):
first time:
HIGH: 669 LOW: 643
HIGH: 721 LOW: 642
HIGH: 668 LOW: 649
HIGH: 722 LOW: 649
HIGH: 669 LOW: 642
HIGH: 721 LOW: 643
second:
HIGH: 669 LOW: 649
HIGH: 722 LOW: 649
HIGH: 668 LOW: 648
HIGH: 722 LOW: 648
HIGH: 669 LOW: 642
HIGH: 722 LOW: 643
third:
HIGH: 668 LOW: 642
HIGH: 722 LOW: 642
HIGH: 669 LOW: 642
HIGH: 722 LOW: 642
HIGH: 674 LOW: 642
HIGH: 722 LOW: 642
So i created this code:
void setup()
{
pinMode(7, OUTPUT);
}
void loop()
{
/*
HIGH: 668 LOW: 642
HIGH: 722 LOW: 642
HIGH: 669 LOW: 642
HIGH: 722 LOW: 642
HIGH: 674 LOW: 642
HIGH: 722 LOW: 642
*/
digitalWrite(7,HIGH);
delayMicroseconds(668);
digitalWrite(7,LOW);
delayMicroseconds(642);
digitalWrite(7,HIGH);
delayMicroseconds(722);
digitalWrite(7,LOW);
delayMicroseconds(642);
digitalWrite(7,HIGH);
delayMicroseconds(669);
digitalWrite(7,LOW);
delayMicroseconds(642);
digitalWrite(7,HIGH);
delayMicroseconds(722);
digitalWrite(7,LOW);
delayMicroseconds(642);
digitalWrite(7,HIGH);
delayMicroseconds(674);
digitalWrite(7,LOW);
delayMicroseconds(642);
digitalWrite(7,HIGH);
delayMicroseconds(722);
digitalWrite(7,LOW);
delayMicroseconds(642);
delay(2000);
}
The led on the remote blinks faster then when I normally press a button and it doesen't work...
The GND of the remote and arduino are common.
I've connected the DATA pin on the TX module of the remote to the pin 7
Where's the problem?
Sorry for my bad english!