Arduino Mega USB Programming

Greetings, I was wondering - surely it must be possible to bypass the USB on the arduino mega to use it from the arduino-side as a port?

The application would ideally route sensor data to a computer to allow high-level java software to control the arduino based on sensor data and user feedback.

Not sure what you mean by "bypass". The USB port on an Arduino (including the Mega) is simply a FTDI USB serial converter chip. This is used to communicate to the Arduino IDE, mapped as a com port.

Once a user program is loaded and running on the board, it's free to use that USB serial link to communicate to any PC based program that can talk to a serial port. The Mega has three other serial links available also, but just as TTL data pins, and would require voltage converters to talk to RS-232 or other voltage standards.

Lefty

If I were to write a program that used the USB’s serial port
to send analog sensor data from the arduino to the PC
(which is what I’d like to do) how would I then be able to
reprogram the arduino? Would opening the editor and
sending a new program through the USB just interrupt
the arduino’s communication with the PC, and accept
the new program?

Also, what kind of code would allow me to address the USB
as a serial port?

Much appreciated Lefty,

Charles

Would opening the editor and sending a new program through the USB just interrupt the arduino's communication with the PC, and accept the new program?

Also, what kind of code would allow me to address the USB as a serial port?

  1. Yes, when the Arduino IDE needs to download a new program to the Arduino board it does an auto-reset to the board which stops any running program and allows the built in bootloader to accept a new program from the IDE.

  2. The Arduino serial communications functions are all that is needed to send data from the Arduino board to a PC via the USB serial link.

http://arduino.cc/en/Reference/Serial

Lefty