Week 12 : Interface and application programming

Apr 18-25 2018

Things to do :

  • Write an application that interfaces with an input and/or output device that you made
  • Include original code


For this weekly assignment I started whit Python.I already installed Python3 in Input device week,in order to check the python version I wrote the command in the terminal : python3 -V and I veryfied that the version installed was the 3.5.2.
My goal for this week was to create a simple interface ( like a button ) that could turn on the led I provided in my Hello Board.
To do that I needed something to manage the serial comunication and a library for the GUI.
Knowing nothing about python I read this tutorial thanks to the wise advice of Dario

  • PyQt5 tutorial
  • Pyserial

  • Now I had to install those library I needed .
    First of all I had to install Pip3.As it said in the link pip is a package management system used to install and manage software packages written in Python.
    To do this step I used the command
    sudo aptitude install python3-pip

    Next I updated pip and installed the libraries I needed:
  • sudo pip3 install --upgrade pip
  • sudo pip3 install pyserial
  • sudo pip3 install PyQt5

  • Whit python correctly installed I wrote a simple Arduino's code to manage the led behaviour when the board receive something from the serial port. In particular if it receive '1' turn on the LED and if it receive '0' turn off the LED.

    Then I flashed it into my Hello board and I moved on coding in python.To create my interface in PyQt5 I followed the tutorial I linked above in particular for manage Buttons,Labels and Geometry.
    The code isn't hard to understand and it has some comments to explain what every parts do.

    I saved it as interface.py in a desktop's folder called interface.Opened the terminal inside this folder and typed
    python3 interface.py
    and this is the final result :


    I liked starting to code something in python.Even if I didn't realize a great weekly project due to fact that I had the exams session in this month I found python very pleasant to learn.I hope to master it in the future.


    click here to download the codes I made.