I am trying to make a group of LED dim with PWM to a MOSFET. The code seems to work for this, but the trouble is that the IR receiver will only receive the signal to turn on the lights and then IR receivers onboard LED goes to a permanent dim state (which is suppose to be off completely). It then refuses to take input until a Arduino reset is preformed. I purchased another IR receiver and placed it in the same configuration and it work exactly as intended I could brighten the LEDS and I saw the PWM stretch on my oscilloscope with every click of my remote. The trouble is that the receiver quickly quit working at this point I think there is a problem with my circuit. I am attaching the circuit diagram in hopes that someone can help.
Thanks, Billa
#include <IRremote.h>
int led = 9;
int led2 = 10;
int brightness = 0; // how bright the LED is
const int RECV_PIN = 7; //IR Receiver Pin
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
analogWrite(led, brightness);
analogWrite(led2, brightness);
if(irrecv.decode(&results)) //this checks to see if a code has been received
{
if(results.value == 0xFF906F) //if the button press equals the hex value 0xC284
{
Serial.println("Triggered U");
brightness = brightness + 5;
}
if(results.value == 0xFFE01F) //if the button press equals the hex value 0xC284
{
Serial.println("Triggered D");
brightness = brightness + 5;
}
irrecv.resume(); //receive the next value
}
delay(100);
}