Pattern creations by sensing body motion 6

CONNECTING 4 SENSORS WITH 6 ANALOG PINS

I was testing bends sensors if they are working with LilyPad (3.3V) although they need 5V power. Later I connected them with accelerometer (3 analog pins; x,y and z).

 

conn

 

It is always good to check serial monitor or printed values to see if values are stable (if not maybe connection is not good) and to see min and max values in case of mapping. If values are not stable also Processing drawing application draw in strange ways which you don’t want.

 

Screen Shot 2014-07-07 at 11.49.20 PM

 

sens_six

The last drawing application includes different parts from research and previous drawing application. The idea was to use negative space and represent the line as drawing element and at the same time like eraser to create new white canvas. All the elements are interacting with each other.  Square is mapped just between blue and green tones. The line changes colour in the same way as squares that produce repetitions with changeable colours.  The application explores different relations between colours and shapes.

line_negative

 

Screen Shot 2014-07-10 at 10.14.26 PM

Screen Shot 2014-07-10 at 10.15.21 PM

Screen Shot 2014-07-10 at 10.15.43 PM

Screen Shot 2014-07-10 at 10.16.02 PM

 

 

Processing code:

import processing.serial.*;

float sensorX=0;
float sensorY=0;
float sensorZ=0;
float last_sensorX=0;
float last_sensorY=0;
float last_sensorZ=0;
float blueValue=0;
float redValue=0;
float greenValue=0;

Serial myPort;

void setup() {
size(840, 600);
background(255);

fill (0);
rect (70, 30, 700, 570); //black background

println (Serial.list());
myPort = new Serial(this, Serial.list()[6], 9600);
myPort.bufferUntil(‘\n’);
}

void draw() {

fill (0,greenValue,blueValue); //blue to green tones
rect (sensorX+100, sensorY+40, 20, 20); //small, changing colors

fill  (255);
rect (200,200, 150, 150); //black infront

stroke (redValue, greenValue, blueValue);
strokeWeight(2);
line(last_sensorX+150, last_sensorY+150, sensorX+150, sensorY+150);

stroke(255);
strokeWeight(1);
line(last_sensorY, last_sensorZ, sensorY, sensorZ);

stroke(255);
strokeWeight(1);
line(last_sensorX+300, last_sensorY+300, sensorX+300, sensorY+300);

fill (redValue,blueValue,greenValue); //changing colors
rect (550, 200, 150, 50); //same size and position
last_sensorX=sensorX;
last_sensorY=sensorY;
last_sensorZ=sensorZ;

}

void serialEvent(Serial myPort) {
String inString = myPort.readStringUntil(‘\n’);

if (inString != null) {
inString = trim(inString);
float[] colors = float(split(inString, “,”));
if (colors.length >=6) {

redValue = map(colors[0], 0, 1023, 0, 255);
greenValue = map(colors[1], 0, 1023, 0, 255);
blueValue = map(colors[2],0, 1023, 0, 255);

// map the x,y,z from the incoming sensor value
sensorX=map(colors[3],380, 780, 0, width);
sensorY=map(colors[4], 380, 780, 0, height);
sensorZ=map(colors[5], 380, 780, 0, width);
}
}
}

 

 

Leave a Reply