I’ve managed to get a reliable circuit going for sending and receiving data from the Tamagotchi. I used an Arduino program written for interacting with the Lutron Maestro light dimmer and modified it to work with the Tamagotchi, plus an infrared LED connected to an output pin.
This program takes care of modulation, although I had to fiddle with the frequency a bit until it worked. I debugged it using a second Arduino running the decoding program I wrote in the last section, which turned out to be problematic, as the actual Tomagatchi is more sensitive than my receving program. I ended up tweaking timing variables blind until it worked with a Tamagotchi (this took maybe 25 attempts).
Circuit noise also became a problem once the IR LED was attached, so I soldered the components into a perfboard with short(ish) wires, which seemed to clean it up.
My set-up can now simulate a Tomagotchi interacting with a real Tamagotchi. The next few entries will explain what I’ve learned about the protocol from this.