3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

GUI Controlled LED Matrix

Step 5Programming the User Interface

Programming the User Interface
«
  • full matrix.JPG
  • blank matrix.JPG
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.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
87
Followers
16
Author:Technochicken(BuildIts)