Some progress

Since I had the code working for loading a single image, I went ahead and modified it to load the images based on the states of the digital input pins as I had before. This time, as I mentioned, I kept all of that in the setup() function and left the loop() function empty.

The sample code from Adafruit already has a check for the status of the LCD so I don’t have to add any kind of wait to be sure it’s initialized before the image is loaded. I did add a wait to be sure that the input pins are in a stable state before they are read. I made the delay 2 seconds, which is dramatic overkill, but it’s also less time than it takes most of the emulators to load. So once the game is ready to be played, the buttons should be labeled.

I uploaded this new code to all of the Arduino Pro Minis. This was a frustrating experience, because about 2/3 of the time, when I plugged in a new Arduino, the IDE would say that it could not find the device on the COM port. Sometimes trying to upload with nothing connected would clear out whatever the problem was and then the upload would go fine once the Arduino was connected. Sometimes it required logging out a of and back in to Windows. And sometimes I had to reboot.

I added superglue to four of the LCDs to hold the SD extenders in place. There are a couple of square holes on the socket, so I put a drop in each of those.

I let that cure overnight. Meanwhile, I put all of the newly programmed Arduinos into the circuit boards I have for them.

I wanted to test things out before putting everything back together, but of course the buttons are all disconnected and their wires are just kind of sitting there where they could make accidental contact. So I unplugged the controller boards for the Raspberry and connected a generic PS-like USB controller.

I connected one of the Arduinos to one of the LCDs with the glued-in extender.

I loaded up a ColecoVision game on the emulator, and after two seconds, an image appeared on the screen! But it was the image for X-Men, not the image for ColecoVision. I was really worried that I would have to change the code on the Arduinos, which would have been quite the hassle.

I looked as my list of games, and saw that ColecoVision is number 5, while X-Men is number 69. Or, in binary:

Coleco: 0000101
X-Men: 1000101

I took a look at the code for decoding the input pins:

int convertPinsToInt() {
   int out = 0;
   if (digitalRead(7)) out += 1;
   if (digitalRead(6)) out += 2;
   if (digitalRead(5)) out += 4;
   if (digitalRead(4)) out += 8;
   if (digitalRead(3)) out += 16;
   if (digitalRead(2)) out += 32;
   if (digitalRead(1)) out += 64;
   return out;
}

The input pins on the Arduino float high, so I thought that Pin 1 must not be properly connected. That pin being high when it should be low would account for the difference. I took a look at the relay for pin 1, and found that the negative wire was not connected. Instead, it was connected to the relay that I am using to control power to the Arduinos and LCDs.

So the next step is to move that wire and make sure it’s working as expected. Then, glue all the other extenders into the LCDs!

Leave a comment