May 17th:
16 Interface and Application Programming

Useful Links:

Python



This week our aim is to write an application to interface with an input or an output device that we have made. We should try to explore and experiment with as many tools as possible in order to familiarise with the many languages and options we could use to achieve this outcome.

I will try to focus on using Python scripts to make a visual output window, and I will olso possibly attempt to look into JavaScript for web scripting. I am also interested in pusuing AppInventor for android app control, or by using python to create a web-server and page to control and monitor an arduino remoteloy. It would be nice for my main project to design a graphic interface in order to relay information and status for the solar tracker. You could program to visually monitor things such as the current direction in motion, the power indication and eventual power output from the solar panels, or battery bank charge status. Furthermore, I could encorporate real-time control to the motors, as a manual override function in order to demonstrate and test the motion of each axis. This could be done in a number of ways to enable remote monitoring and control over a computer and web-browser based application, or remotely via InfraRed, bluetooth or radio to a wireless control board with buttons or a joypad as was discussed and explored during last weeks networking module.

I began by properly installing the Python sourcecode, I had previously installed Python version 3.6, now I aslo installed version 2.7 to make sure I would avoid any compatability issues by using this earlier version. We will again be using the serial port connection in order to communicate through python with our AVR circuit boards, similarly to within the Arduino IDE. In order for python to have access to the serial port you first need to download pyserial port extension module, and add this file to the C:\\Python\Lib\site-packages, then install it using the command line.

So my initial sketch for what I wanted to achieve is as follows:


In order to undertand what I needed to do I gained some valuable help and advice from our instructor Xavi, and by reading up and the following some tutorials and guides on the net:


Then to check my connection is working I wrote a simple hello. echo code function to check the communication bewteen arduino and python. I installed the pygraphics. module, in order to be able to define a window for my app. and then to define coordinates and boundaries of diferent shapes and assign colours. Then I had to figure out a way of setting the conditions in order to change and highlight the colour of each directional arrow, this was done by placing markers or serial write phrases into my arduino code, which are then processed with a 'serial read' phrase within my python script to give the visualisation in the graphic display window.