avana LLC

Interface and Application Programming

MIT'S BRIEF

Write an application that interfaces with an input and/or output device that you made.


-programming the board
-programming the processing code
-video


This week assignment involves creating an application that interacts with one of the previously created boards. I will connect my button board I made on week 6 which has an input device ,a button, to communicate with a serial port (FTDI header).

Programming the board


To make an interface for my button board I had to program the board itself. Since my board has an FTDI header on it, I used the serial communication for sending and receiving data from the board.
To program the board with my modified C code, I installed AVRDude.The programmer used the .make file to install the .c file onto my ATtiny44 microcontroller and program successfully worked to turn the button on and off with a press of the button.

First Test.


The first example of Interface I tried was the Simple Read example. Basically, a simple square responded to the clicks of my button, changed color from gray to black in two steps.

While I run my code, I got the following message on the Serial monitor:"dududududududu".



First test video



Second Interface


In order to make my Interface more interesting, I wanted to change the square into an image. I uploaded an SVG file (bot1.svg) and placed in the folder. I did that by loading an example stored in the Geomerative library.

In processing I selected which port to read, where my board was connected, as shown below: and I placed the .svg file (bot1.svg) in the to run.

Here is my code:

import processing.serial.*; import geomerative.*; RShape grp; RShape circle; boolean ignoringStyles = false; Serial myPort; // Create object from Serial class int val; // Data received from the serial port float t=0.01; void setup() { size(600, 600); // I know that the first port in the serial list on my mac // It is always my FTDI adaptor, so I open Serial.list()[0]. // On Windows machines, this generally opens COM1. // Open whatever port is the one you're using. String portName = Serial.list()[0]; myPort = new Serial(this, "/dev/tty.usbserial-AI049V5J", 9600); smooth(); // VERY IMPORTANT: Allways initialize the library before using it RG.init(this); grp = RG.loadShape("bot1.svg"); RG.setPolygonizer(RG.ADAPTATIVE); RG.setPolygonizerAngle(0.045); grp = RG.polygonize(grp); circle = RG.getEllipse(0, 0, 20); circle = RG.centerIn(circle, g, 220); } void draw() { if ( myPort.available() > 0) { // If data is available, val = myPort.read(); // read it and store it in val println(val); } if (t > 0.98) { t = 0.01; } else if (val == 100) { t = t +0.01; } println(t); translate(width/2, height/2); background(#2D4D83); noFill(); stroke(255, 200); RShape circleSeg = RG.split(circle, t)[0]; RG.setAdaptor(RG.BYPOINT); RShape adaptedGrp = RG.adapt(grp, circleSeg); RG.shape( adaptedGrp ); RG.shape( circleSeg ); }



DOWNLOAD FILES.