week1 main image
× Home About Assignments Final

Week14 - Interface and application programming

Assignment:

Group Assignment:

1# Compare as many tool options as possible

Individual Assignment:

1# write an application that interfaces with an input &/or output device that you made.

Group Assignemnt

For this week's group assignment, we have looked over different softwares that allow us to build interfaces for our boards. for our group project, I tried WXPython. WXPython is really really similar to tkinter, however, unlike tkinter it works better with Macs. I was able to put images for my buttons and have navigation bar on my window. I was able to set the size and location of my window. Unlike in tkinter, I was able to change the color of my buttons, etc.

wxPython

However, just making a simple navigation bar that has only one item that does not even do anything took 66 lines of code and really long time of going through the tutorial. wxPython is a really powerful tool that enables the user with a lot of different options from aesthetics to functionality, however, it is not as easy to use as tkinter which is another pythonbased interference library.
My other group mates have done similar trial and research for other softwares for making an interference. You can access this file from here

Individual Assignment

For this week's individual assignment, I have decided on using one of my old boards. For this I had to select from the ones that are still working and that have an FTDI cable connectors. The only one thta was fitting the specifications was the fish board I made previously. You can read about how I made it here

Week 7

Unfortunately, it took me 3 hours to debug this board. At first, I tried to upload my code and see if it works. I know that my code had some issues with Serial communication, so I was already scared that it wasn't going to work. When I uploaded it, and tried to run it nothing happened. Then I went back to my code and tried to add an LED turn on to check if the Serial.available is greater than 0. However, even when I did that the LED did not turn on. Hencei I speculated that my Serial connections were not working, so I thought that my wiring was wrong so I took some dupont wires and changed the location of the TX and RX wires. The reason why, I did this is because I thought maybe I accidentally connected RX on the FTDI cable with the RX on the Attiny rather than the TX and viceversa. However, to no avail, my board was as silent as it gets. I then started suspecting that maybe my ATtiny is gone for good. However, just as I was suspecting that, a little change in my code made the Attiny work again. weirdly it only worked time to time and whenever, I tried to record the phenomenom on the phone, it just stopped working. Finally, I decided to change the Attiny1616 with ATtiny 3216 and I uploaded my code and VOILA!!!!!!! IT WORKSSSSSSSSSZZZZZZZZZZZZZZZZZZZ!!!!!!!!!!!!
It was a miracle, I used the Serial Monitor on Arduino to check if it worked and it worked.

week14 v1 gif

To make this code work, I learned many different things. In week7 I tried it so that I will get an input from the Serial Monitor and convert it to binary and display it. However, I found it too difficult to do it. However, this time, I learned that I can actually do Serial.readString() to read the whole Serial Monitor input as String and then use that. Moreover, because converting string to binary is relatively hard in arduino, and because I am going to do a interface with python, I decided that I am going to make the converter at the Python end and send the binary as a string to the Arduino code. This allowed me to solve it so easily.

week14 Arduino Code

After completing my Arduino code, I focused on the Pythong Tkinter code. I created 2 buttons and an input field. One button for submiting the value entered in the input field and the second button for quiting out of the application.

week14 Python Code

As you can see in the code I define the port as '/dev/cu.usbserial-A10JEITZ' I got this port name from arduino. When I plugged my FTDI cable to my computer, in arduino IDE at under tools/ports I found /dev/cu.usbserial-A10JEITZ as the FTDI cable programmer. Using this address I was able to define my port in python.

week14 port selection

Moreover, in the code you an also see a part where I wrote res = ''.join(format(ord(i), '08b') for i in entry.get()) port.write(res.encode()) This part of the code, takes the input from the user, converts it to binary and loads it to a string and sends that string back to Arduino as bytes using Serial communication.
The end result looked like this:

week14 Finale

A weird thing that I found out that, when I clicked to fullscreen mode, for some reason the program stopped working but when I made it small screen it started working again.

week14 Finale actual

The video above shows the user entering a normal english text and the Tuna Fish Board displaying it in binary by turning the LEDs on and off. The difference between week7 and this week's code is that, last week, I have tried to convert user's input from the Serial Monitor in Arduino IDE to binary however, I was not successful for some reason. This can be because my Attiny1616 might have been fried. However, now using python I was easily able to convert a normal english string to binary.

Access my files:

You can access my files here --> Tuna's Fab Academy Folder