Constant current IR LED circuit

An area for more general discussion by the user community for topics not covered elsewhere
Post Reply
User avatar
AnalysIR
Site Admin
Posts: 301
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Constant current IR LED circuit

Post by AnalysIR » Fri Nov 22, 2013 3:55 pm

We recently publish a blog post about a constant current IR LED circuit.

See http://www.analysir.com/blog/2013/11/22 ... d-circuit/

If you have any questions about the article or circuit or enhancements, please comment here.

User avatar
AnalysIR
Site Admin
Posts: 301
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: Constant current IR LED circuit

Post by AnalysIR » Fri Nov 22, 2013 5:22 pm

Sample code used in sketch to generate a circa 37kHz modulated signal @ 50% duty cycle is below:

Code: Select all

/*
  Sample modulation signal
  Turns on an Pin 7 on/off for 13 uSecs, repeatedly.
  This example code is in the public domain.
 */
 
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
  pinMode(7, OUTPUT);   //modulated signal is on Pin 7  
}

// the loop routine runs over and over again forever:
void loop() {
 while (true){   
  digitalWrite(7, !digitalRead(7)); 
  delayMicroseconds(6);  //also allows for delay/ovehead caused by all of the code in this loop             
 }
}
Note: if you are sending IR use IRremote, IRLib or PWM to generate your modulated infrared signal. This code is for testing and measurement purposes only.

Post Reply