Mishin Control

Information

This article was written on 18 Oct 2012, and is filled under ICM, Physical Computing.

Serial Communication again.

So, I lost my code. So I went and re-did it, with varied results. This time, much better and it didn’t take all day (maybe only a half of one).

Code is in the comments (if not for yours, then for me).

Now, on to do something a little different, but kind of the same….

One Comment

  1. HannahMishin
    10/18/2012

    Processing:
    import processing.serial.*;
    Serial myPort;
    int xPos=1;

    void setup(){
    size(500, 500);
    println(Serial.list()[0]);
    myPort = new Serial(this, Serial.list()[0], 9600);
    myPort.bufferUntil(‘\n’);
    background (0);
    }
    void draw (){
    }

    void serialEvent(Serial port){
    String inString = myPort.readStringUntil(‘\n’);
    if (inString != null){
    inString = trim (inString);
    float inByte = float (inString);
    inByte = map(inByte, 0, 1023, 0, height);
    stroke (127, 34, 255);
    line (xPos, height, xPos, height-inByte);
    if (xPos>=width){
    xPos=0;
    background(0);
    }

    else{
    xPos++;
    }
    }
    }

    and simple Arduino:

    void setup(){
    Serial.begin(9600);
    }
    void loop(){
    Serial.println(analogRead(A0));
    delay(10);
    }

Leave a Reply