Problems with Arduino and Razor 9dof

Hey, I'm having some trouble reading data from my Sparkfun Razor 9dof through my Arduino board. I'm using an Arduino Mega 2560 and Windows 7. The trouble is that the code below uploads to the board fine, but does not give an output to the serial monitor.

void setup() { Serial.begin(38400); }

void loop() { if(Serial.available()) { Serial.print(Serial.read(), BYTE); } }

I know the board is working fine as I tested it using an FTDI breakout board and was able to see the raw data.

I was just wondering if anyone knew how to fix this code, or if anyone had another code for reading the raw data through the Arduino.

Thanks, Matt.

How is the Razor connected to the Arduino and how is the Arduino connected to your PC?

The razor is connected to the Arduino using serial ports (Tx0 to Rx1 and Rx1 to Tx1) and the Arduino is connected to the PC through USB.

The razor is connected to the Arduino using serial ports (Tx0 to Rx1 and Rx1 to Tx1) and the Arduino is connected to the PC through USB.

So, the razor and the PC are using the same serial port? On an Arduino with 4 serial ports, why?

Or are some of those names wrong? They are not consistent, at least.

Are the grounds connected?

I think it's because the razor and the Arduino us different naming conventions, i.e. Arduino will have a serial with Tx0 and Rx0 while the razor has a serial called Tx0 and Rx1. And yeah, everything else was connected up correctly.

I decided to abandon this code anyway, I managed to find another online which actually worked.

Thanks for your help, Matt.

could you please post the code that you found, I've been having the exact same problem for weeks now and can't get the stupid thing to work

#include <NewSoftSerial.h>

void setup() {
Serial.begin(57600);
Serial1.begin(38400);
Serial1.print(4);
}
void loop(){
if(Serial.available()>0) {
int incomingByte = Serial.read();
if(incomingByte >=48 && incomingByte <=53)
Serial1.print(incomingByte, BYTE);
}
if (Serial1.available()>0)
Serial.print(Serial1.read(), BYTE);
}

I think this is the code. Looking back the problem pointed out by PaulS regarding using the two ports at once may have been what was wrong. If you’ve got the Arduino connected to your PC via a USB you cant use Tx> and Rx<.

If this doesn’t work (the code i’m using now has been modified) give me a shout and i’ll try and find the right one.

Matt

I tried running it but couldn't get a print out when I opened the serial monitor.

Based off your code you've obviously connected the razor to the serial1 port, just to double check (tired it both ways) do you have Tx connected to Rx and Rx to Tx or Tx-Tx, Rx-Rx, I've read people doing both and am not 100% sure which is the correct connection. I've got a strong programming background but am new to using serial connections.

Thanks for your help

If you’ve got the Arduino connected to your PC via a USB you cant use Tx> and Rx<.

Well, you can use the arduino tx>to both the >rx on the USB and the >rx on another gizmo. Been there, done that.