I am working on a project that uses infrared LEDs to send signals at certain intervals. The arduino I was planning to use would've been sending data @ 9600 mbps, and sent a signal, such as "hi" every ten seconds. Then, the arduino on the other side would send back "hello".The only problem is do I have to use the RX and TX pins or can I use any pin on the Board?
3 Answers
Using RX and TX makes it possible to utilise the UART functionality. If you're going to use an ordinary IO pin you will need to fix the bit-to-byte conversation yourself in software.
As Dejvid_no1 states the UART is possible. Additionally SoftSerial Library can support other pins.
Note that if your IR is modulated then you will need to account for that. Example 38K demodulator typically require 2 to 10 cycles to detect a transition. Hence only 3.8K baud rate is practically achievable. Hence 9600 will be problematic.
Additionally note using IR either without or with the same modulation for both transmit and receive, it will be constrained to half-duplex.
Without modulation you will significantly more susceptible to ambient noise. And therefore you should employ either an CRC or LRC. (later much easier and sufficient).
Since you will end up with modulated IR, you have to drive the IR led yourselves. For that, a PWM pin, or a simple digital output pin will work better, since you can not utilize the TX functionality anyhow.
- The TX sends serial signals, i.e. it sends out a continuous 5V if you're sending 11111111.
- The infra led has to be pulsing, on-off at 38Khz as a sender. Then you can use an off the shelf receiver, http://www.vishay.com/docs/82491/tsop382.pdf to receive it.
- Note that the output of the receiver is inverted. Either you shall take into account that in sending (i.e. send no light when 11111111, and send light pulses for 0), or you better go with a software serial port, and decode the received data yourselves. In that case you don't need the RX either.
Note: consumer infrared uses a different modulation. Instead of continuously sending infrared flashes for "1", it is using a Manchester modulation (google for RC5) or some other modulations. Less infrared flashes - longer battery lifetime. :)