Sebastiaan FabAcademy

Week 16 Interface and Application Programming

website version1.0

This weeks assignment is very new to me. I have no experience what so ever with this topic. Also this week I have a lot to do in my FabLabEnschede. I have to prepare for the Maker fair Twente where the FabLabEnschde celebrates its 5th anniversary. I will present there ( booth 21 and 23 ) my FabAcademy work and therefor I also had to make several parts for the leafBot to be able to display the Robot on the Makerfair. Come to see the Maker fair Twente and enjoy your self. I have made a special website page Making parts in my final project section of my website. In this website I show the steps in creating these parts.

Because this weeks assignment everything is new to me, it was difficult to start. Someone advised my to look to Processing. That is what I did, and I started by downloading Processing 3.1.1. Next I followed the first online Tutorial. I was amazed by the possibilies of this software. The online training was very helpfull to me and I was able to follow it very well.



This week the task is to write an application that interfaces with an input &/or output device that you made. I made in Week11 an sonar sensor application to measure distances with several sensors. I took this as a basis to start with.

During the weekend on Sunday I had time to look at the Processing tutorials. Paul give me the tip to use the Arduino example sketch SerialCallResponse to communicate between Arduino and Processing.



Below the Arduino Ping sketch with was designed in Week11 to measure distances. Next thing was to implement this Arduino sketch in to the SerialCallresponse. But my time was limitted on this Monday, because I had to help several customers. I had to ask FabLabEnschede volunteer Frank to give some explanation in to processing and how to adapt the Arduino Sketch. This was very helpfull for me.



First copy the defining of the values in the SerialCallresponse sketch.



Setup of the pins and define the maximum distances are copied in the SerialCallresponse sketch.



A variable is a place for storing a piece of data. It has a name, a type, and a value. A possible 4e sensor is added because my PCB is designed to connect 4 distance sensors.



The void setup is not changed from the SerialCallresponse sketch.



The void loop is changed. The 4 sensors NewPing 1/2/3 and 4 are implemented in the sketch. When the measured distances are out range an 0 is diplayed.





I verified this new sketch. An error occured. The Trigger pins, Echo Pins and max distance where not declared. I had to change this. In the picture the pin 1 and 2 are changed, the pins 3 and 4 not yet.



I verified the sketch again. A error occured. Behind FourthSensor a double = = was copied in the sketch. I removed the double =.



I verified this new sketch. An new error occured. I disconnected the FabKit and connected it again to my labtop.



I verified this new sketch. No error occured. I uploaded this sketch in the FabKit.



The processing sketch is been copied out of the Arduino SerialCallRespons sketch and copied in an new Processing sketch. Next was to change the Processing sketch. The following steps are changed.
First the background and frontcollour where defined.
Because of 4 sensors the serialInArray is increased from 1 to 4.
Then an interger to define the 4 grafiks is defined.
Next in void setup the stage size is increased a bit.
The starting postioning of the ball was removed. I want to start from the left side.
In void draw an rectangular is defined instead of an ellipse. I want to have horizontal grafics, so the height of the positionings off the grafical rectangulares are defined.
In void serialEvent "If we have 3 Bytes" it is changed to 4 bytes (4 sensors). The 4 sensors are defined to the Xpositioning.
In print the values 4 sensors are added Xpos1 / xpos2 / xpos3 / xpos4.
I removed the begin_max5_patcher




I had only 1 sonar sensor and I connected it the my PCB and connected it to the FabKit pins 12 and 11. See Week11 why I connected it to these pins of the FabKit.



First test. It did something. The first 2 sensor connections responded to my moving hand.

I looked to the values. Its seems a bit strange that the values have 4x0 zeros and then a distance value.

I changed the divide by 4 to make the range 0-255 to 3 and later removed this out of the void loop. Also changed the serial count from 4 to 3. I tried this and this give a much better result and showing only measured distances.

I connected the sensor to the second and thirth PCB connection and FabKit. It worked also.

A last movie to show the result of this weeks assignment.

Due to time reasons, I had to help customers in the FabLabEnschede, I was not able to test more different software options.

Arduino 4 Sonar Sensor sketch




Arduino 4 Sonar Sensor SerialCallResponse sketch



Processing Serial