As it turns out, communicating on an infrared beam is easy as hell with PIC Micro Pascal. And the circuitry is crazy-simple as well. The photo above shows the transmitter, and here is its schematic:
An infrared LED and resistor is all it takes! I bought my LED surplus from All Electronics several years ago. Now, even with this simple circuit one can easily communicate over more than a dozen feet. To increase the range even further, you could drive the LED with a transistor and bump the current. This is perfectly safe, since the LED only conducts intermittently. That is, we're using a pulse code modulation, the carrier running at 38 kHz. So, the ON-times are quite brief, and most LEDs can handle short bursts of higher than usual current. Here's the data sheet for the unit I used:
According to this, the device has an absolute max current rating of 100 mA.
I decided to use the Sony television remote control code format. See the source code for more details, and don't forget we've already seen how to read such a remote control in a previous exercise.
The receiver is equally trivial:
I've connected up eight ordinary LEDs. When you run the demo, the transmitter sends the numbers one through eight sequentially, and the receiver displays the number detected.
Here's the circuit for the receiver:
Again, I'll refer you back to the remote control exercise for details on the sensor used here.
And here's a quick demo showing the communication in action:
The download files, below, contain the schematics and source code for both the transmitter and receiver.
Click to get the source code.
Click to get the schematic PDF.
Next Project: MIDI -- Output Demo