Hi All
I am playing with a 433Mhz Transmitter and Receiver , captured the data on my digital scope so now I want to
reproduce (Decoding) the results with a Nano.
I want to start reading the data after a HI pulse of 2300uS , every few seconds the Receiver gives out 2 pulses equal to 3050uS.
The serial monitor displays these pulses with a lot of zeros in between , this should not happen .The 2300uS pulse
must first be detected and were does the Zeros come from ?
Serial monitor: This should not happen.
123
0 0 0 0 0 0 0 3051 3364 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3049 3360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3050 Decoding
123
0 0 0 0 0 0 0 3050 3362 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3049 3367 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3048 Decoding
123
0 0 0 0 0 0 0 3047 3368 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3047 3361 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3049 Decoding
123
0 0 0 0 0 0 0 3049 3361 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3050 3354 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3048 Decoding
123
0 0 0 0 0 0 0 3054 3365 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3042 3364 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3048 Decoding
123
0 0 0 0 0 0 0 3053 3366 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3052 3363 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3053 Decoding
When Transmitter is pressed.
123
0 0 0 0 0 0 0 3056 3366 0 0 0 0 0 0 0 0 0 229 231 223 227 229 218 228 226 220 226 225 222 219 224 218 221 2325 455 450 447 429 449 Decoding
123
0 0 239 230 230 231 224 224 223 224 221 222 211 218 213 225 222 217 2335 451 204 443 449 445 210 216 445 435 446 446 422 434 440 194 431 203 203 201 201
const unsigned int numReadings = 40;
unsigned int myArray[numReadings];
const int readPin = 2; //D2
long startmilis;
long endmilis;
long duration;
long sync = 0;
int count = 0;
int val1 = 0;
//==================
void readSyncLow()
{
sync = pulseIn(readPin, LOW);
}
//==================
void readSyncHi()
{
sync = pulseIn(readPin, HIGH);
}
//==================
void setup()
{
pinMode (readPin, INPUT);
digitalWrite(readPin, HIGH); //internal pull-up
Serial.begin (9600);
}
void loop()
{
Serial.print("Decoding");
sync = 123;//Test value ..Does not change after readSyncHi ????
while ((sync > 1000) && (sync < 2400))//Must be around 2300uS
{
readSyncHi();
}
for (unsigned int i = 0; i < numReadings; i++ )//i = 100
{
duration = pulseIn (readPin, HIGH);
myArray[i] = duration ;
}
Serial.println(" ");
Serial.println(sync);
for (unsigned int i = 0; i < numReadings; i++)
{
Serial.print ( myArray[i]);
Serial.print(" ");
}
delay(5000);
}
Thanks in advance for any help.