suit WELCOME TO MY logo WEEK 17

RETURN TO HOMEPAGE

Interface and Application Programming

Ok Hi pals?.. this week we`re covering Interface and Application which duly brings in a cool range of skills as it somewhat integrates hardware and software engineering techniques in this week's task which is:
To Write or Modify an application so as to interface with an Input & or Output device..
I decided to try interfacing with output display via Processing..I chose to work with processing and arduino libraries since most elements are readily available and easy to import..I was intending to simulate or rather create any form of effect since it was my first try at interfacing real components
pcb.....pcb

Ok this is the code I used in the interfacing hoping it would work..
import shiffman.box2d.*;
import processing.serial.*;

Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph

void setup () {
// set the window size:
size(600, 600);

// List all the available serial ports
println(Serial.list());
//Alright pals considering u`ve chosen to use arduino always set the opening port to zero
//Hence the need to open serial as such... Serial.list()[0] or rather if you`re on avr or any other open it up.
myPort = new Serial(this, Serial.list()[0], 9600);
// Please do not generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0,255,0);
}
void draw () {
// everything happens in the serialEvent()
}

void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');

if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);

// draw the line:
stroke(0,0,255);
fill (0,130,125);
ellipse(xPos, width, xPos, height - inByte);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(127,0,56);
}

else {
// increment the horizontal position:
xPos++;
}
}
}

OK you can download from >>> Download Interface code

I was also in for a few errors like this one which bust me trying to use the same serial as the one in arduino.. I forgot I`m in Processing..
pcb

We`ve learnt so much in class I thought it`ll be prudent if I review and practice as I continue with the rest of the weeks assignment..I stumbled upon this tutorial while scratching the web..Processing & Arduino