Week_14 Assignments
- Group assignment
- Individual assignment
We needed to try different methods to make a GUI that allows user to interface with the controller/machine/device.
To build an application a GUI that interface (inputs/outputs) with a device.
Group assignment
We used scratch to arduino application to control an LED using a lion shaped button.
We used processing to get the readings of a moisture sensor presented on a sliding bar.
Individual assignment
For my assignment I wanted it to be part of my final project I wanted to make the GUI where The machine can be controlled. And could look like this:

I used tkinter package to build up the GUI and pyserial package to communicate with the arduino.
Before I created a virtual environment to make a space where i can experiment with packages and versions without damaging or get confused if I had to try more than one version. I already had python 3.7.9, python 3.6.6 and python 3.12.1 but I used 3.7.9. When you are installing python (whichever version) make sure you check the add to path box.

I followed the amazing tutorial of Mr. Paul Mcwhorter on how to make a virtual environment.
- First go to the directory where you want to put the virtual environment.
- Then you type this line py3.7 -m venv myVenvironmentName
- After that I wanted to check if I am running inside the virtual envronment or not I typed python
- What needed to be done is the activation of the environment before using it.
- Then while th eenvironment is active I installed tkinter using pip.
- I don't like using the terminal so I will use VScode to write the python script.
- I navigated to the folder I of where my virtual environment is. Then created a python file. Then hit Ctrl+Shift+P to open the interprter.
- Then chose the interpreter of the environment I created.
- When you hit the run button the python script you write opens a terminal below.
- Where we can install pyserial notice that the environmentis active.
- I started with importing tkinter and followed a great tutorial where I learned how to make a window, title, buttons, canvas, sliding bars and more.
- After I tested these buttons I wanted to test the communication with the arduino an this where I began to use pyserial and where I ran into a problem.
- I connected the LCD with the arduino and printed what the arduino received from the python script on it and this where I ran into another problem.



As you noticed the virsion running is python 3.12.4 not the version I want which is 3.7.9



.png)



Here I added buttons and tested the homing button through printing homing using a function I defined. While the Bye button kills the window and the program using destroy() method.
The problem was that arduino serial monitor and the python script are using the same port which means that the arduino can't print what I send from the python script on the serial monitor while the python script tries to send. I searched for solutions but I figure a nice one that fits as an output device and a way to debug the messages I connected to the arduino an LCD display.
The error I faced:

As you can see the message doesn't appear for some reason. That reason that pyserial write() method sends bytes and I mess the interpreting in the arduino side but nooooooo this was not the reason the reason is that I sometimes I over look the simple things and over complicate things. It was I had mismatching baudrates. yeah just like that.
