tsop 1738 and IR led

Hi, I'm trying to make an obstacle sensor with tsop 1738 and IR led, and I need to set led frequency 38kHz
now my code is:

//this variables are not changing
const int ir_left = 2; //IR led
const int tsop = 5; //TSOP1738

//starting tsop state
int tsop_state = 0;

void setup(){
pinMode(tsop, INPUT);
pinMode(ir_left, OUTPUT);
Serial.begin(9600);
}

void loop(){
digitalWrite(ir_left, HIGH); //set led on
tsop_state = digitalRead(tsop); //tsop
Serial.println(tsop_state); //print tsop state
delay(3000);
}

so what is missing?

so what is missing?

Something to drive the LED at 38kHz.

:slight_smile: well I realize that :smiley: so maybe u know how to drive led at 38kHz. Do I need to modify hardware? Or I can do it in program code?

You could use a 555, or you could drive it with software - 38kHz is only a 26us cycle time.
Your choice.

ok, thanks