alkopop79
YaBB Newbies
Offline
Posts: 46
Re: Smooth/ease values from sensors
Reply #4 - Jan 3rd , 2010, 12:25pm
The actual result should be smoother. As I move my hand slowly towards or away the sensors, the values flickr/jump/bounce. The values are represented with the x and y position of the cross. By the way, the sketch: //use the 'standard firmata' for processing library! import cc.arduino.*; import processing.serial.*; import promidi.*; PFont font; Arduino arduino; MidiIO midiIO; MidiOut midiOut; int sensor1; int sensor2; int cs1= width/2; Note note; void setup(){ size(500,500); arduino = new Arduino(this, Arduino.list()[1], 57600); arduino.pinMode(7, Arduino.INPUT); arduino.pinMode(6, Arduino.INPUT); arduino.pinMode(5, Arduino.INPUT); midiIO = MidiIO.getInstance(this); midiOut = midiIO.getMidiOut(1,"IAC Driver - Bus 1"); midiIO.printDevices(); println(Arduino.list()); } void draw(){ background(0); fill(255); smooth(); rectMode(CENTER); noStroke(); int cs1 = constrain(sensor1,0,height); int cs2 = constrain(sensor2,0,500); rect(cs2,cs1,10,40); rect(cs2,cs1,40,10); sensor1 = arduino.analogRead(0); sensor2 = arduino.analogRead(1); midiOut.sendController(new Controller(1 sensor1=3*sensor1*sensor1-2*sensor1*sensor1;,sensor1/4)); midiOut.sendController(new Controller(2,sensor2/4)); println(cs2); delay(10); if (arduino.digitalRead(7) == Arduino.LOW){ note = new Note(64,64,1); midiOut.sendNote(note); fill(255); ellipse(width*0.3,height/2,80,80); println("HIGH"); } else { noFill(); stroke(255); ellipse(width*0.3,height/2,80,80); } }