14. Interface and application programming
This week I was not very focused on the weekly assignment as I had a lot of ideas for my final project and decided to focus on that. For the weekly assignment, I decided to do something very simple, in order to fulfill the requirement. I just wanted to get a potentiometer reading on my Arduino to display along a circular "eye" in Processing.Group Assignment
The group assignment for this week can be found hereString Woes
To do this, I wrote a simple Arduino code which reads a potentiometer connected on pin 4 and sends the reading out through serial, followed by a new line for every reading. This Processing code then grabs the data on serial and maps it (crudely) to the position of an eye in a circle taken from one of the processing example codes. It took me much longer than I would like to say to read the serial data correctly... At first the conversion would just give me a 0 for all values (basically a null result), I thought I needed to get rid of the new line character in the string, so I did by making the string equal to itself starting at space 0 and ending at string length -1. After this did not work and some further testing, I finally realised the string was being read with extra characters as I tested the string length which would return an extra length each time! So I redid the conversion making the string equal to itself -2, with val being my received string : val = val.substring(0, val.length() - 2); This gave me the integer conversion I was expecting! I was then able to make the eye move somewhat following the potentiometer movement. I say somewhat because it is not linear due to the initial code of the eye, and it only works on one side... I realise this is very low effort for this week, but I had a lot to work on between designing and making double-sided PCBs and trying to figure out advanced SERCOM issues... Here is the video of the potentiometer controlling the eye!