For the laptop and Raspberry Pi Pico to communicate and stream data to each
other without WiFi, we used a USB serial cable. The controller blasts data
across the cable to the Mac port (where it is read), while the Mac sends data
across that port to the controller. Both devices read from their respective
ports (for my Mac, it was /dev/cu.usbmodem1101).
Using the PySerial Python library, I initialized a serial connection to the serial USB port on my MacBook to allow the Python script on the laptop to stream data to the Pico and read data from it as well. The baud rate was also initialized to 115200 to ensure the devices' listening and data streaming speeds were in sync. Baud rate is the speed of data transmission and listening, or how many bits are transmitted across the USB and read at the port per second. If the serial's baud rate is too low, it will struggle to understand the incoming data from the controller and send data too slowly for the controller's processing speed.
The code above shows how the serial connection was initialized.
The code above shows how the serial connection was used to send data from the laptop to the Pi Pico. After the CNN outputs a consistent, final prediction, the predicted letter was encoded into the UTF-8 format. UTF-8 is a system that encodes English letters into bits, grouping each letter into a 1-byte space. We do this because an electronic device can only understand bits (0 and 1) rather than the letter itself.
The encoded letter is then written to the Mac port that connects via USB to the microcontroller chip.
Physical Connection Format
The Mac is connected to the Pico via a dual-sided USB cable. The USB-A side of the cable is adapted to a USB-C dongle to plug into the Mac. The MicroUSB side connects to the Raspberry Pi Pico. On the far left is a breadboard with LEDs and resistors.