I have an Arduino Uno, a Digispark with an IR shield, and an idea for using them to communicate four 0-255 values.
The idea is that I would have the Arduino generate a 1-second pulse that switches between 4 different frequencies, one for each value I want to communicate. The Digispark would detect that a pulse had begun, wait 125ms (until the middle of the first pulse segment), then sample the frequency, wait 250ms (until the middle of the next segment), then sample the frequency, and so on. It was slightly confusing even to me, so I made a diagram:

(The colors are to differentiate between segments, not to indicate frequency. You may have guessed that I intend the values to control a servo and an RGB LED.)
Background info:
- The receiver is the one that came in the DigiSpark IR shield kit. It was shipped as part of the original Kickstarter project, in case that matters.
- I have an 850nm and a 950nm IR LED, both from SparkFun.
- I want to use IR because the DigiSpark part of the project will be portable while the Arduino part will be stationary.
- I have some experience programming for Arduinos, less experience with hardware design, and almost no experience using hardware-constrained platforms like the DigiSpark.
My questions:
- Is it possible to generate and receive tones like this? I don't expect much accuracy (5% is good, 10% is acceptable). If so, what frequencies should I use to represent values of 0 and 255?
- It looks like
tone() and noTone() analogWrite() [Arduino] and analogRead() [DigiSpark], are the functions I need, is that correct? [Edit: analogWrite is obviously the one to use if analogRead is detecting it, not sure why I thought otherwise] - Are interrupts the best way of detecting when a pulse has started? If not, what is?
- Do you see any other potential problems?
Thanks for your help.