Which OpAmp are you using? I have a 6 month old that I needed a trigger for a Fisher Price with IR remote when she started up. I have bread-boarded out an LM358N that works well. I am guessing you have a LM386N...
I was going to have lm358, but when i went to maplin electronics shop, they havent had that in stock since 2011, so i got a ts358cd and tl072cn instead!
Try this sketch, it is sloppy but it might have some pieces that you can use.
// This sketch will send out a trigger signal for FP Baby Entertainment.
// this code is public domain, please enjoy!
int IRledPin = 11; // LED connected to digital pin 11
const int ledPin = 13; // the number of the LED pin
const int thresholdvalue=100;//The threshold to turn the led on
const int analogPin = 0;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the IR digital pin as an output:
pinMode(IRledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int mn = 1024; // mn only decreases
int mx = 0; // mx only increases
// Perform 10000 reads. Update mn and mx for each one.
for (int i = 0; i < 10000; ++i) {
int val = analogRead(analogPin);
mn = min(mn, val);
mx = max(mx, val);
}
int sensorValue = (mx-mn);
if(sensorValue>thresholdvalue)
SendCode();
digitalWrite(ledPin,HIGH);//if the value read from A0 is larger than 400,then light the LED
delay(250);
digitalWrite(ledPin,LOW);
Serial.println(sensorValue);
Serial.print(millis());
Serial.println();
}
// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}
void SendCode() {
pulseIR(940);
delayMicroseconds(900);
pulseIR(940);
delayMicroseconds(880);
pulseIR(940);
delayMicroseconds(880);
pulseIR(940);
delay(10000);
// delay(1200000); // wait 20 minutes before commanding it again
}