The objective for this week was to write and application that
interfaces with an input &/or output device. I used Python to write
a very simple application that would allow me to control the output
some LED's.
Choosing the Output
A few weeks ago during the input devices week I had accidentally
connected my input device to digital pins rather than analog ones so
I was unable to use it for that week. Luckily, I had already
attached two LED's to the board that worked great, so to save time
I decided to use that board as an output device for this week's
assignment.
Programming the Board
I used Arduino to upload a program to the board. Throughout this
enitre project I found
I basically took Rich's Arduino code and tweaked it to include two
LED's.
The code initializes the serial port using the "SoftwareSerial"
function. Then it sets the two LED's as output pins and begins
listening to the serial port. Then it activates and deactivates the
LED's depending on the input from the computer.
Creating the GUI with Python
Once again I found Rich's page to be extremely well documented and
helpful so I used it to understand how to program the interface with
Python. Here is the python code I used to create the GUI shown to
the right.
Using python to create the interface was the hardest part for me
this week mostly because I was having a hard time finding the board
through serial communication. After figuring out how to use pyserial
from the link above I was finally able to get the GUI to work.
For all of the Python code, I used Python 2.7 and edited the code in
the IDLE interface.
Mistakes I Made
The biggest issue I had was that I missed the lecture this week since
I was in Texas for Thanksgiving so I had a really hard time even
understanding the basics of what we had needed to do. It really helped
looking at other people's pages but it still took me a quite a long
time to learn everything. As a result, my interface isn't the most
sophisticated GUI but I'm just happy I was actually able to get it to
work!