// processing code for reading sensor values from 3 Maxbotix LV EZ-1 Sensors
import processing.serial.*; // reference the serial library
import cc.arduino.*; // reference the arduino library
Arduino arduino; // create a variable arduino of the Arduino data type
PFont f;
int signalPinOne = 7;
int signalPinTwo = 6;
int signalPinThree = 5;
int triggerPin = 12;
void setup() {
size(1400, 800);
f = loadFont("CourierNewPSMT-48.vlw");
smooth();
println(Serial.list()); // List all the available serial ports:
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(triggerPin, Arduino.OUTPUT);
}
void draw() {
//triggers pin to pulse on each loop through
arduino.digitalWrite(triggerPin, Arduino.HIGH);
delay(50);
arduino.digitalWrite(triggerPin, Arduino.LOW);
delay(50);
background(40);
frameRate(30);
int valueOne = arduino.analogRead(signalPinOne);
int valueTwo = arduino.analogRead(signalPinTwo);
int valueThree = arduino.analogRead(signalPinThree);
// println((valueOne/1.8333));
// println((valueTwo/1.8333));
// println((valueThree/1.8333));
// display large read out of Inch value of sensor #1
float a = (((valueOne)/1.8333));
fill(255, 255, 255);
textFont(f, width/18);
text("Sensor # 1", 0, width/7.2);
textFont(f, width/6);
text(a, width/4, width/7.2);
// display large read out of Inch value of sensor #2
float b = (((valueTwo)/1.8333));
fill(255, 255, 255);
textFont(f, width/18);
text("Sensor # 2", 0, width/3.33);
textFont(f, width/6);
text(b, width/4, width/3.33);
// display large read out of Inch value of sensor #3
float c = (((valueThree)/1.8333));
fill(255, 255, 255);
textFont(f, width/18);
text("Sensor # 3", 0, width/2.2);
textFont(f, width/6);
text(c, width/4, width/2.2);
delay(100);
}
Any help is much appreciated. Thanks!