Week 14


Interface and application programming

This week my goal was to learn a new language (Python) to write an application in connection with my board of last week (because I need the USART module which is only on my last board).

I wrote a program for my board (the one of last week) in C such that when the board receive a letter, it does something.

Program_board

Then I downloaded Python here and also Pyserial here (for the serial communication between my computer and my board). I started learning Python on codeacademy because there are a lot of exercices and it's really funny but they use the old version of Python and I wanted to use the 3.x version. That's why I continued with openclassroom which uses the latest version of Python and is also more complete (but this is in french!).

After understanding the basics, I started to write my program. To permit and configure the serial communication between my board and my program in Python, I used Pyserial and in particular this page and I quickly obtained what I wanted.

Program_pyserial

I then decided to create an interface and chose simplicity using tkinter (instead of wxpython) because it was already installed in my version of Python and I successfully imported it in my program. For this I found a lot of help online but the most helpful website was this one.

I had everything I needed so I just started to write my program and after a few hours I obtained my application ! This is not so nice but it works perfectly and I learned a lot of stuffs!

Python_program

So this is my program and when I run it on the IDLE of Python 3.x, a window appears and I can play with the RGB LED on my board (see below).

Demonstration Demonstration

After that I wanted to improve my application. I modified the program in my board in order to control the power of each color of my LED (with a Timer PWM in software like I did during the week 11). I also modified the program for my application in Python to change the interface. It was a little bit more complicated because I had to send integer via the serial communication but I found a way to do it and here is the result (:

Improvement

Program in C for my board.
Program in Python for the application.

Software and website used

NotePad++    Pyhton    PySerial    Arduino