Arduino to Processing - 3x Maxbotix LV EZ-1 Daisy Chained

Hi everyone,

I am currently running Standard Firmata in Arduino 0022 with an Arduino Nano V3 ATmega328. I am running a simple program to display sensor values from each of the three sonars. I am using Processing 1.5.1.

My problem: The program I wrote does not run properly when I translate it to the Processing IDE. In the Arduino IDE everything works great. When in processing I am using Standard Firmata to establish the connection between Processing and my board.

I have three Maxbotix LV EZ-1 Sonars connected to the Analog inputs: 7, 6, and 5. The Sonars are chained through TX and RX connections to fire in succession. I am using Digital Pin 12 to fire the signal. Here is my code in Arduino:

// Arduino code for reading sensor values from 3 Maxbotix LV EZ-1 Sensors

int signalPinOne = 7; int signalPinTwo = 6; int signalPinThree = 5; int triggerPin = 12; // output pin to start Ultrasound signals

void setup() { Serial.begin(9600);

pinMode(triggerPin, OUTPUT); // set this pin to output //give the sensors time to boot up delay(250);

} void loop() { digitalWrite(triggerPin, HIGH); delayMicroseconds(30); digitalWrite(triggerPin, LOW); delay(50);

int valueOne = analogRead(signalPinOne); //Listen for echo int valueTwo = analogRead(signalPinTwo); int valueThree = analogRead(signalPinThree);

Serial.println(); Serial.print("UltraSound Value ONE"); Serial.print( "= "); Serial.print((valueOne/1.8333)); Serial.println(); Serial.print("UltraSound Value TWO"); Serial.print( "= "); Serial.print((valueTwo/1.8333)); Serial.println(); Serial.print("UltraSound Value THREE"); Serial.print( "= "); Serial.print((valueThree/1.8333)); Serial.println(); Serial.println();

delay(500);

Serial.println(); Serial.println();

}[/font][/font][/font]

Here is the code I am using in Processing when Standard Firmata is uploaded to the Arduino:

// 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!

One more thing... When I run the processing sketch with Standard Firmata uploaded to the board I do get accurate sensor readings only from sensor THREE. The other two sensors read 0.

The Processing sketch you are using expects the Arduino to recognize messages sent to it, in the Firmata format. Your sketch is not doing that.

You are doing analogRead on pins 5, 6, and 7. The UNO and other non-Mega variants do not have analog pins number 6 and 7. Firmata is not well supported on the Mega.

So, what board do you have?

Thanks for your input. For that sketch I was using an older Arduino Nano V3. I don’t believe this board is in production still. The nano V3 uses the ATmega328 chip.

I have tried this with an Arduino Uno and have gotten exactly the same result.

I have tried this with an Arduino Uno and have gotten exactly the same result.

You are using non-existent analog pin numbers. That you do not get good results is hardly surprising.

The Arduino nano V3 has 8 analog pins. When I tried the program on the Arduino Uno I switched my input pins to 0, 1, and 2. I still did not get acceptable results. The surprising part was the inaccurate readings. Thanks for trying.

I switched my input pins to 0, 1, and 2. I still did not get acceptable results.

When you are using all 3, is one reading what appears to be consistently right? Does the right one change if you change pins around? In other words, is pin 0 always right, regardless of which sensor is plugged in? Is there any delay between reading the pins?