I programmed the program and GUI that control the LED matrix in Python, using the built-in Tkinter
graphics module. The design of the GUI is very simple. It contains nine buttons, each representing one LED. When the buttons are clicked, they turn orange, and when they are clicked again they turn white. As the buttons are clicked, they update the LED matrix in real-time.
In order for Python to communicate with the Arduino, it needs the Pyserial
module. Once this is installed, you can read and write to the Arduino over the serial connection.
In my program, whenever a button is clicked, the button calls a function which writes the number of the button to the Arduino. Using that number, the Arduino figures out which LED the number corresponds to, and switches the state of that LED.
The Python file for the UI is attached below. When running it, there are a few things to note:
If you run the file in Windows, it is advisable to simply double click the file instead of opening it in IDLE (the python IDE) and running it from there. Also, you will have to set the serial port to use within the code. By default, it is set to 2, which corresponds to COM3 on Windows.
Mac users: I have not tested the program on a mac. Please let me know if there are any problems with it, so I can try to fix them. Python sometimes behaves differently on Macs, especially when dealing with graphics stuff.