Riva,
I've been trying to work with your advice/sketch.
Does the circuit have an impact on the signal?
I have built the same circuit as...
"The schematic used to be available in the forum post referenced above, but seems it has now been removed. The sniffing circuit is now part of RFToy circuit. If you check this schematic:
the lower right corner, it’s basically two resistors (47K and 10K) connected in series from the receiver’s data pin to GND, plus an audio jack. You also need 5V to power the receiver. You don’t need the MOSFET as that’s meant for the micro controller."
I've then tried to adapt your code so that it just puts out one code, to make it easy to see if I'm heading towards getting the right thing.
However, I appear to be getting a lot of nonsense, see the attached..
Here's the code as I've adapted.
// High/Low microsecond timings, first value is high timing, the rest alternate low/high
const int hlUsTimings[] = {
1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 453, 453, 453, 453, 453, 453, 1746, 453, 453, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 1746, 453, 453, 453, 453, 9863};
const int hlUsSize = sizeof(hlUsTimings) / sizeof(hlUsTimings[0]);
const int pinChangeDelay = 0; // Value to subtract from numbers to compensate for instruction timings
const int outPin = 10; // Transmitter output pin
const int ledPin = 4; // LED output pin
void setup() {
pinMode(ledPin,OUTPUT);
pinMode(outPin,OUTPUT);
digitalWrite(outPin,LOW);
delayMicroseconds(1000);
delay(5000);
}
void loop() {
for (int i = 1; i <= 1; i++)
{
digitalWrite(ledPin,!digitalRead(ledPin));
byte pinState = 0;
noInterrupts();
for (int y = 0; y < hlUsSize; y++){
pinState = !pinState;
digitalWrite(outPin,pinState);
// if (pinState == 0){
// delayMicroseconds(20);
// }
int z = hlUsTimings[y] - pinChangeDelay;
delayMicroseconds(z);
}
interrupts();
}
delay(5000);
}
Riva:
Can you post the captured audio as a WAV file so we can look at it in detail and check timings please.
If all you need to do is repeat the sequence then maybe modifying the below sketch to suit your timings.
// High/Low microsecond timings, first value is high timing, the rest alternate low/high
const int hlUsTimings[] = {
380,440,700,800,360,440,720,780,380,440,700,800,360,460,700,780,380,440,700,800,360,800,360,460,720,13000};
const int hlUsSize = sizeof(hlUsTimings) / sizeof(hlUsTimings[0]);
const int pinChangeDelay = 0; // Value to subtract from numbers to compensate for instruction timings
const int outPin = 3; // Transmitter output pin
const int ledPin = 4; // LED output pin
void setup() {
pinMode(ledPin,OUTPUT);
pinMode(outPin,OUTPUT);
digitalWrite(outPin,LOW);
delayMicroseconds(13000);
}
void loop() {
digitalWrite(ledPin,!digitalRead(ledPin));
byte pinState = 0;
noInterrupts();
for (int y = 0; y < hlUsSize; y++){
pinState = !pinState;
digitalWrite(outPin,pinState);
// if (pinState == 0){
// delayMicroseconds(20);
// }
int z = hlUsTimings[y] - pinChangeDelay;
delayMicroseconds(z);
}
interrupts();
}
I have also attached the schematic for the final item and also a static image of my breaking down the timings for the sketch.