Infrared Diode Wont work

Hi all....

Its my first Post and my first questions.... is it possible that a Arduino Nano (Atmega328) is not fast enough to trigger a IR led to shutter my DSLR?
My Camera dosent snap and i dont see a error in my code :frowning: could i test if the infrared diode is working?

My code is the following

// On-Board LED and Phototransistor for Pentax K-X

int analogPin=3; //phototransistor connected to analog pin 3
int ledPin=13; //led is connected to pin 13 (on-board led)
int voltm=0;
int irPin=6; //infrared led is on pin6

void setup()
{
pinMode(ledPin,OUTPUT);
pinMode(irPin,OUTPUT);

Serial.begin(9600);
}

void loop()
{
	delay(0);
voltm=analogRead(analogPin); //read the phototransistor
Serial.println(voltm);
if (voltm>1)
{
digitalWrite(ledPin,HIGH);
digitalWrite(irPin,HIGH);
delay(13); 
digitalWrite(irPin,LOW);
digitalWrite(ledPin,LOW);
delay(3); 
digitalWrite(irPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1); 
digitalWrite(irPin,LOW);
digitalWrite(ledPin,LOW);
delay(1); 
digitalWrite(irPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1); 
digitalWrite(irPin,LOW);
digitalWrite(ledPin,LOW);
delay(1); 
digitalWrite(irPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1); 
digitalWrite(irPin,LOW);
digitalWrite(ledPin,LOW);
delay(1); 
digitalWrite(irPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1); 
digitalWrite(irPin,LOW);
digitalWrite(ledPin,LOW);
delay(1); 
digitalWrite(irPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1); 
digitalWrite(irPin,LOW);
digitalWrite(ledPin,LOW);
delay(1); 
digitalWrite(irPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1); 
digitalWrite(irPin,LOW);
digitalWrite(ledPin,LOW);
delay(1); 
digitalWrite(irPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1); 
digitalWrite(irPin,LOW);
digitalWrite(ledPin,LOW);
delay(1000); 

}

else
{
	digitalWrite(ledPin,LOW);
	digitalWrite(irPin,LOW);

}
}

For Pentax it need 13ms on, 3ms off and then 7x on(1ms)/off(1ms)
that is what i have already from the internet and what all google searches give me out.

I also took deeper look in the already existing DSLR classes, but i could not catch why my camera is not triggering.

Thanks already for an answer that could help...

You can use a cellphone camera to check if the IR LED is functioning. Point the camera at the LED and turn the LED on, you should see it glow on the cellphone screen.

Thanks for the answer, i can see the infrared light, but the camera trigger would not start...
could it be that there is something wrong with my programming?

could it be that there is something wrong with my programming?

Most consumer devices controlled via IR use an IR base signal that is usually ~38khz. Does your camera require the same?

yes it requires 38khz … i did think its enough just to send the signal on off on off…

how i can set it , that the ir led is using 38khz?

You should use digitalRead then.
The remote control might make a conflicting pulsetrain (interference).

Just for experimental purposes, how about not using the photo-device and using a momentary (pushbutton) switch to cue the pulse-train?

The following sketch uses a pushbutton to initiate the pulsing.
Wire the [pb]pbas you see in Fig 5.5 of the following link
http://www.ladyada.net/learn/arduino/lesson5.html
If you don’t have a pushbutton then use a wire.

byte pbswitch = 3;  // 
byte trigstate;      // used with pbswitch

byte ledPin = 13;   // shows pulsetrain active
byte irPin = 6;     // 

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(irPin, OUTPUT);
  pinMode(pbswitch, INPUT);
  // Serial.begin(9600);
}

void loop()
{
  trigstate = (digitalRead, pbswitch);
  if (trigstate == HIGH);
  {
    digitalWrite(ledPin,HIGH);
    digitalWrite(irPin,HIGH);
    delay(13); 
    digitalWrite(irPin,LOW);
    delay(3); 
    
    for(int idx = 0; idx < 7; idx++)
    {
      digitalWrite(irPin,HIGH);
      delay(1); 
      digitalWrite(irPin,LOW);
      delay(1); 
    }
    digitalWrite(ledPin, LOW);
    delay(1000);  // wait 1 sec for re-activation
  }
}

The following sketch uses a pushbutton to initiate the pulsing.

But unless you're using the Arduino output to gate a source of a 38kHz square wave to feed your LED, it still isn't going to work.
Try searching for Ken Shirrif's IR remote library.

AWOL,
Oh, so that pulsetrain is supposed to modulate a 38KHz carrier?
Didn't consider that.
I thought that was just the OP's photodevice.
OK.

Another thing to watch out for is that many IR LED's require 100 mA of current, far more than an Arduino pin is capable of. Use a small NPN transistor to switch the LED on and off and a resistor to limit the current to 100 mA.

Well, they don't "require" it; many can do with 100mA, but that's the outer limit (it's a max not a min.)

For the one from Radio Shack (http://www.radioshack.com/product/index.jsp?productId=2062565) the 100 mA is the nominal current draw, not the absolute maximum rating. People who have tried to run one directly off an Arduino pin have found that the output is very low, capable of remote control only over a range of two or three feet. Since the original poster didn’t say how far away the camera was I thought it would be good to mention this possibility.