Jacob Libby

Week 14

hero shot

Interface and Application Programming

A week dedicated to learning about Graphical User Interfaces and discovering how to implement GUIs



group lab

We began this week with the group project of developing a simple version of a GUI. To accomplish this, we used Python2, the command line/terminal, and the pySerial and tkinter libraries. We had downloaded python online before the lab, and downloaded the libraries using pip: "pip install pyserial" and "pip install tkinter" on Windows OS. From there we began to create a program to send serial output to an arduino. We took a ton of time to troubleshoot (having problems with Python3, installing the incorrect library (serial instead of pyserial), and random pip errors as well), and eventually we got our led to light up by using the command line!




group lab 2

After this, we began to create a simple GUI, which allowed us to control the LED by pressing buttons on the screen rather than typing into the command line. This was super cool and was surprisingly easy with the packages we installed. We used the functions we created before and set-up the buttons so that when they were clicked, they would call their corresponding function and turn on/off the light!




group lab 2

We then looked into different softwares as a group to compare them and their use cases. My group worked with the tkinter library, wxpython, and the Processing software. Tkinter was a super cool library and was definitely the easiest to use. It was quite straight-forward and seemed a bit more plug-and-play than the others. Both tkinter and wxpython required python, but no other additional software or installations (other than the obvious pip installs). Wxpython was a little more finnicky for me, and was probably my least favorite of the bunch. It seemed that it was similar to tkinter, but for how I was testing the softwares, tkinter was my favorite of the two. Setting up a hello world took surprisingly long, and attempting to do anything above that ended up working or not working for unknown reasons. Processing was my favorite tool and was incredibly reminiscent of Arduino. For some reason, I had a difficult time importing libraries, but after a few YouTube tutorials, it made a little more sense, and I got some codes working.



kiCad

For the individual section of the week, I wanted to work on a GUI that focused on reading and interpretting an input from the board rather than sending an output to the board. To do this, I started by delving deeper into the different softwares we looked at in the lab, and landed back on Processing. I really liked how similar Processing is to Arduino, and it left more natural to move back and forth between them. To begin, I chose to use my board that had two buttons, in order to make the GUI more interesting. I started by working in Arduino.



Arduino Code

In Arduino, I created a sketch that would send either an 'l' or 'r' in Serial, depending on if the left or right button was pressed. This was in hopes to have the processing code read in the characters from the Serial and interpret them as indicating either the left or right button on the board.



Processing Code

I then moved on to thinking of fun ways for code to interpret inputs. I searched far and wide, and landed on a particle simulator I found using Processing. The code created particles from the top middle of the GUI window, and continued creating particles until the code was closed. For my project, I spent a while editing the code in order for it to work for my needs.



I wrote the code so that when a button was pressed on the board, it would send a serial character ('l' for the left button and 'r' for the right button) to the Processing code. The Processing code would then read the character and then create a particle either on the left or right side of the the screen! I was super happy with how it came out and am excited to implement something similar in my final project!



Files:
Lab Python Code
Individual: Arduino Code
Individual: Processing Code