hi
i am trying to get six sensors chained together so they constantly loop and send their readings into maxmsp using the arduino2max code, as i discovered the other day that they cant all just 'free run' like i had them set originally as they give inaccurate readings
i have spent most of the day doing the rewiring as is detailed on the maxbotix site here :
http://www.maxbotix.com/uploads/Chaining_Application_Notes__AN_Output_Constantly_Looping_.pdf
but now i am having trouble with adapting the arduino2max code which is where my knowledge lets me down
it says on the page "you will have to "kick start" them, (at least 250mS or more after power is applied to the sensors to give the sensors this time to boot-up). To do this, pull the RX pin high on the first sensor for at least 20uS. Then the micro controller will have to return it's pin to a high impedance state so that the next time around the TX output from the last sensor will make it's way to the RX of the first sensor. Then all of the sensors in the chain will run in sequence." but i am having trouble turning this in the required code
can anyone help me with writing this bit of code? as you see in the example i have tried to use the digital pin 12 to do the 'kick starting' but i just keep getting error messages and i get stuck
many thanks for any help in advance
int x = 0; // a place to hold pin values
int ledpin = 13;
int kickstart = 12;
void setup()
{
Serial.begin(115200); // 115200 is the default Arduino Bluetooth speed
digitalWrite(13,HIGH); ///startup blink
delay(600);
digitalWrite(13,LOW);
pinMode(13,INPUT);
}
{
digitalWrite(12,HIGH); /// this is the code i have managed so far but i am a bit stuck
delay(20);
digitalWrite(12,LOW);
}
void loop()
{
if (Serial.available() > 0){ // Check serial buffer for characters
if (Serial.read() == 'r') { // If an 'r' is received then read the pins
for (int pin= 0; pin<=5; pin++){ // Read and send analog pins 0-5
x = analogRead(pin);
sendValue (x);
}
for (int pin= 2; pin<=13; pin++){ // Read and send digital pins 2-13
x = digitalRead(pin);
sendValue (x);
}
Serial.println(); // Send a carriage returnt to mark end of pin data.
delay (5); // add a delay to prevent crashing/overloading of the serial port
}
}
}
void sendValue (int x){ // function to send the pin value followed by a "space".
Serial.print(x);
Serial.print(32, BYTE);
}