I want to produce a 1200hz square wave for an IR Led to communicate with a IR receiver. Is this something you simply do use PWM? If so, what would the code be for that? Any help is appreciated!
Thanks
--dave
I want to produce a 1200hz square wave for an IR Led to communicate with a IR receiver. Is this something you simply do use PWM? If so, what would the code be for that? Any help is appreciated!
Thanks
--dave
You could do it just with software, but it depends what else you want to do at the same time.
Hi AWOL,
Basically I'm just trying to create a IR beacon for a Lego Mindstorms robot. I have an IR receiver for the robot, which expects a 1200hz square wave from the IR transmitter. So, i don't really want to do anything else with the arduino except to control the output of the IR Led. (I'm sure the arduino's overkill, but I have one and I know how to program it.) Thanks again.
--dave
1200Hz is only a cycle time of 833microseconds.
A couple of "delayMicrosecond"s and a couple of "digitalWrite"s is all it needs.
You may need to experiment with the delay periods, depending on how critical your timing is.
I wonder what would happen if you used tone(); in Arduino 0018 ? I can't see it outputting a sine wave somehow Somebody care to put a 'scope on it ?
And, if you're running an earlier version than 0018, there are some other examples for generating frequencies. Like this one and this one.
Thanks pluggy,
I've never seen the tone() function before. Looks like it might do the trick. I'll give it a try.
--dave
So, i don't really want to do anything else with the arduino except to control the output of the IR Led.
Just giving it a 1200HZ wave is not going to do anything for the Mindstorms robot. You have to modulate it with serial data, that is you have to turn it on and off, when it is on it is actually pulsing at 1200Hz.
You could do this with a PWM set at 50% but you will have to change the PWM signal frequency to 1200Hz. Search this forum for how to do that, there are some libraries or some register pokes.
Pluggy, thanks! I used the tone( ) function and it works perfectly. I'm able to specify a 1200hz wave and the Mindstorms robot can detect it just fine.
Grumpy_Mike, I didn't need to send any serial data, since I'm not sending commands or data to the Mindstorms robot--just sending out a modulated IR source to act like a lighthouse beacon for the robot. I have an IR receiver on the robot that handles the rest--determines the direction and strength (rough distance) of the IR signal.
thanks all for your help. problem solved!