Making the LED brighter

So I read the first post and I won't say I'm a noob so I'll just say I'm very slightly experienced.

I'm trying to modify code so that when an IR receiver receives any signal, it will turn on an LED for 3 seconds and then turn it off. I have used Ken Shirriff's IRremote code and modified from there. This is my first "real" project aside from the examples so I will expand on this once I get this problem figured out.

Using all of the same equipment & settings, I did the Blink LED sketch and the LED lights up fine. I then upload this code below and the LED will only barely come on. At this point, the code is functioning exactly how I want it to for now except that the LED can barely be seen. Any suggestions to changes I can make?

#include <IRremote.h>

int RECV_PIN = 11;
int led = 13;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    digitalWrite(led, HIGH);  // Turns on LED after receiving signal
    delay(3000);              // Leaves LED on for 3 seconds
    digitalWrite(led, LOW);   // Turns LED off
    irrecv.resume(); // Receive the next value
  }
}

I don't know if you need this information, but I've tried using both a standard yellow and red LED that came with my Arduino kit from SparkFun. I'm using the Arduino UNO and a 38 kHz IR receiver module (part # 2760640 from Radio Shack).

The perceived LED brightness is a function of how long it stays on (time) and how much current flows though it (the resistor for the LED).

As the LED on for 3 seconds in the code, do you see it lit for 3 seconds?

What value of resistor do you have in series with the LED?

marco_c:
As the LED on for 3 seconds in the code, do you see it lit for 3 seconds?

Yes, it does stay lit for 3 seconds as expected.

What value of resistor do you have in series with the LED?

I'm not currently using an additional resistor. I'm only using slot 13 and the ground on the Arduino board and the resistor associated with slot 13.

You should probably use a different pin and resistor. Something line 200 ohm should be safe for most LEDs.

Also, I just noticed that you are not setting the Led pin to OUTPUT in setup?

I got a different result with what I have on hand, but not as much as I expected. All I have on hand are 330 and 10k resistors which came with the kit. I used the 330 with a different port and got probably 3+ times the output as before, but I'd guess I'm still not at half the brightness that happens when you do the standard Blink LED example.

I thought this was a programming issue, but now I'm certain it isn't. I'm wondering if it doesn't have something to do with the current the IR receiver is putting out when it is triggered. I might head over to the LED forum and see if they can provide some more input.

Thanks so much for your help. You at least got me in a somewhat better position.

Your problem could very well be that pin 13 is configured as an input! You need to set it as an output in setup().
Setting an input to HIGH enables its pullup resistor, which effectively gives you a 10-30KOhm resistance in series with your 'output'. That's why it seems so dim; you've got far too much resistance on the LED. If you use pinMode(13, OUTPUT); in your setup() function, it should fix the problem easily.

Wow...that makes perfect sense! I just put my board up for the night, but I changed the code so as soon as I get it back out tomorrow I'll upload that code and make sure that works.

Thanks so much for your help!

You're much welcome! If it doesn't work, just let me know so I can puzzle over it some more.

It just might be a low efficiency led too... put 2 330 ohm resistors in parallel and see if it isn't brighter. The worst case is a red led as it's forward voltage is typically 1.8 - 2.2 V and that would supply about 19 - 20 mA to the LED. Safe for an Arduino port and an LED... I = E/R = 19 ma (5-1.8) = 3.2/ (330/2) = 3.2/165 = .019A or 19 mA. 20 mA is safe for most all Leds I have ever found.

Doc

I'm not currently using an additional resistor. I'm only using slot 13 and the ground on the Arduino board and the resistor associated with slot 13.

Which board are you using?

Edit: Sorry, it's an Uno, in your original post. Looking at the schematic for the Uno, there is no resistor associated with pin (slot?) 13.