I try to use a SRF10 sonar with a Arduino Mega board. I tried this code ( http://arduino.cc/en/Tutorial/SFRRangerReader ) and also some other codes I found on Internet, but I always have the same problem...
My code is running (the sonar is emitting ultrasounds and I can make a DEL blink) but I don't have any access to the USB Serial interface.
Indeed, my card simply don't show up on my computer immediately after the upload (ie /dev/TTYACM0 is not created) and I can't get any Serial.
However, normally Serial works fine. It is a problem that appear when I use Wire.h and it appears as soon as I read data thanks to WIre (immediately after upload, the card doesn't respond with the Serial Monitor).
I didn't find any doc about this problem. Do you know how to deal with it ?
From the /dev/ttyACM0 I guess you have a Arduino Mega2560 and not an Arduino Mega (which uses a ATmega1280 processor and an FTDI chip for the USB to serial adaption).
On the Arduino Mega2560 the communication with the PC is done by the ATmega16U2 coprocessor also on the board. When you use the Wire library you just change the hardware state of the main processor and not the state of the coprocessor. The only reason I can see for your symptoms is that the coprocessor gets reset. My guess is that the power supply doesn't deliver enough current. What do you access with the Wire library, what device is connected to the I2C and how have you connected it?
Wire.beginTransmission(112); // transmit to device #112 (0x70)
// the address specified in the datasheet is 224 (0xE0)
// but i2c adressing uses the high 7 bits so it's 112
Wire.write(byte(0x00)); // sets register pointer to the command register (0x00)
Wire.write(byte(0x50));
works fine and I still have Serial if I only execute this part.
But as soon as I execute Wire.endTransmission() after this code (end of step 1), I loose Serial communication.
I tested the return value of Wire.endTransmission() with a DEL but this function seems to return 0, so it seems it executed just fine...
In fact, I don't know exactly what is happening. But on Linux, /dev/TTYACM* disappears and on Windows, the card doesn't appear anymore in the devices manager.
I think Wire.endTransmission doesn't block because if I had a sample code to make a DEL blink after this code, the DEL blinks (but I still don't have a serial communication).
To test the return value of Wire.endTransmission, I did int error = Wire.endTransmission() and I made a test to make a DEL of a different color blink (RGB DEL) according to the value of error (0 or != 0). The DEL blinked for 0.