Both Processing and vvvv will listen to arduino IDE with Serial comunication. In case of Processing, I use Serial.write. In case of vvvv, I use Serial.println
/* read temperature + capacitive sensor serial write to processing serial println to vvvv */ #include <VirtualWire.h> #include <CapacitiveSensor.h> CapacitiveSensor capSensor = CapacitiveSensor (4, 2); int threshold = 1000; void setup() { pinMode (13, OUTPUT); Serial.begin(9600); Serial.println("setup"); vw_setup(2000); // Bits per sec } void loop() { int tempValue = analogRead(A0); //temperature sensor int capValue = capSensor.capacitiveSensor(30); // capacitive sensor Serial.print(capValue); Serial.print(','); Serial.println(tempValue); if (capValue > threshold) { digitalWrite(13, HIGH); // Serial.write(tempValue); // write in serial for processing } else { digitalWrite(13, LOW); } }
import processing.serial.* ; Serial myPort; float alfa = 0.0; int bgcolor =0; int raw = 0; float easing = 0.05; float smoothDest = 0.0; void setup() { size (800, 200); colorMode(HSB, 255); println("Available serial ports: "); println(Serial.list()); myPort = new Serial(this, Serial.list()[0], 9600); } void draw() { if (myPort.available() > 0) { alfa = 255; raw = myPort.read(); bgcolor = int(map(raw,0,30,1,255)); println(bgcolor); } else { alfa = 0; } smoothDest = smoothDest + (bgcolor-smoothDest) * easing; background(smoothDest, 255, 255); textSize(32); text("processing your prophecy..", 200, height/2); fill(255, alfa); }
Serial communication
Main sketch
read from temperature sensor then calculate
For data visualization
I have noticed a huge amount of disturbing value.. seems like when the capacitive value is over 1000, it disturbs temperature value and that make temperature value wrong
I print the value in this format : capacitive read, temperature readThis screenshot is when capacitive is not touched
Now it is touched. notice that capacitive value is above 1000 and the temperature read is above reality (it should be around 150-160)
Could it be interference ? Is capacitive area to big ? I tried a stupid thing : put a paper on the capacitive surface and it lower the value a lot !
the visualization
Download files : Processing sketch (pde) vvvv patches (zip) used with vvvv_45beta34.2_x86
<< previous | next >>