USB communications on mega 2560

I've just bought a mega 2560. first thing was to connect it to working ubuntu arduino 1 ide and load up one of the string examples via usb cable. it appears to load ok, flashing lights, etc. but no communication between arduino terminal and program.

checked same with uno which works fine, checked that i had selected mega 2560 and i had. Is it possible that you can not serial.print to the usb port? gaaakkk!

it's ok, I'm hoping this is something stupid i've done, but i would have expected usb serial communication to work same on uno and mega 2560.

what gives?

Did you check the Hardware setting and ports on your PC if it match the Arduino USB port ?

I not sure if you need a new driver for the Mega board...

I'm running Ubuntu 10.10 Linux, not windows.

i did get a few of the simple example routines to work, but they are intermittent. could be that the shield is the problem. the pinouts agree, but maybe there is a problem with the reset circuit. need to think about this some more.

i did get a few of the simple example routines to work, but they are intermittent. could be that the shield is the problem. the pinouts agree, but maybe there is a problem with the reset circuit. need to think about this some more.

You've shown no code and now you mention a mysterious "shield." I'm not sure what kind of answers you are expecting. Except: Yes, you can Serial.print() from a Mega 2560 just like you can with a Uno. So something else is up.

here'a the code, look familiar?:
Character analysis operators

Examples using the character analysis operators.
Send any byte and the sketch will tell you about it.

created 29 Nov 2010
by Tom Igoe

This example code is in the public domain.

void setup() {

// Open serial communications:

// send an intro:
Serial.println("send any byte and I'll tell you everything I can about it");

void loop() {
// get any incoming bytes:
if (Serial.available() > 0) {
int thisChar =;

// say what was sent:
Serial.print("You sent me: '");
Serial.print("' ASCII Value: ");

// analyze what was sent:
if(isAlphaNumeric(thisChar)) {
Serial.println("it's alphanumeric");
if(isAlpha(thisChar)) {
Serial.println("it's alphabetic");
if(isAscii(thisChar)) {
Serial.println("it's ASCII");
if(isWhitespace(thisChar)) {
Serial.println("it's whitespace");
if(isControl(thisChar)) {
Serial.println("it's a control character");
if(isDigit(thisChar)) {
Serial.println("it's a numeric digit");
if(isGraph(thisChar)) {
Serial.println("it's a printable character that's not whitespace");
if(isLowerCase(thisChar)) {
Serial.println("it's lower case");
if(isPrintable(thisChar)) {
Serial.println("it's printable");
if(isPunct(thisChar)) {
Serial.println("it's punctuation");
if(isSpace(thisChar)) {
Serial.println("it's a space character");
if(isUpperCase(thisChar)) {
Serial.println("it's upper case");
if (isHexadecimalDigit(thisChar)) {
Serial.println("it's a valid hexadecimaldigit (i.e. 0 - 9, a - F, or A - F)");

// add some space and ask for another byte:
Serial.println("Give me another byte:");

Exact same thing that comes with the download. After more fussing, I find if i load it to the MEGA 2560 from Ubuntu installation of Arduino 1 IDE, it appears to load but will not run and the "L" led flashes slowly. If i change the board to UNO, and load it same way it works. I thought it might matter WHEN I switched the board selection in the IDE so i went all the way out, then reloaded IDE, switched board to MEGA 2560, and no joy - works with UNO, doesn't with MEGA.

Now we come to the good part. It works fine with either board on the Windows XP Arduino 1.0 IDE installation. AND, if I load it using the Windows IDE, it will run both on Windows and Ubuntu, so it must have something to do with the way the IDE loads the code under Ubuntu - possibly something's messed up in the Ubuntu cores, or ??

So i submit that there is a difference in the way the Ubuntu loader works between the UNO and the MEGA 2560 which matters. If there is a difference between the UNO and MEGA loaders in Windows, it doesn't matter.

I might add that I had the same trouble everyone else has loading new sketches over earlier short sketches on the UNO from Ubuntu until I started putting delay(5000) at the head of the setup. Before i caught on to that, I would have to go to the windows installation, which didn't seem to have this timing interface problem, and load a trivial example, which i could then overwrite in ubuntu.

to summarize, problem could be:

  1. UNO and MEGA do not treat USB port same and it matters on Linux but not on pc.
  2. Ubuntu loader that works on UNO but not on MEGA has software problem in cores (maybe)?
  3. soemthing else related to Ubuntu handling of loading on MEGA.

I'm going to try loading my serious code from Windows next to see if it loads properly.

What does the slow flashing "L" mean?

Where did you get the IDE v1.0? Is that version now available on the Ubuntu repository, or did you download it from the Arduino site?

I haven’t checked the repository version in a while.

Hi Tim,
both windows and ubuntu IDE’s were downloaded from Arduino site. A more complex sketch which loads on UNO from Ubuntu IDE does not load correctly on MEGA and produces flashing L. So far, i have not been able to load anything to the MEGA from Ubuntu Arduino 1.0 IDE. I’m running Ubuntu 10.10 and I surely cannot be the only one, can I?

This isn’t something that is going to shatter my day, but it does seem odd. It could be that there actually is a bug in the Ubuntu MEGA load, or the Ubuntu based libraries and core contain something that’s hostile to usb serial, that is not in the pc version.

now that I know i can make this work by loading on windows, it isn’t a big problem, but I’d much rather be running on Linux.

It also appears that Sparkfun’s Screwshield which is a very nice prototyping connection board that works fine with the UNO, doesn’t work with the MEGA. Symptom is bizarre LED flashing which bespeaks reset interface on shield??

i might add that the traces on the prototyping section of this board are connected in a pattern which seems beyond my imagination to use. It would have been nice to have a row down the middle that would support installation of max232 so i could get some rs232 signals in and out, but if there is a way to do this without a lot of trace cutting which is difficult on this very well-made board, i havn’t figured it out, but then topology was never a strong suit of mine.

If anyone wants to pursue any this, I’ll be glad to try other things.

and thanks to all who tried to help me with this.


Did you download the Ubuntu repository version of the Arduino IDE before downloading v1.0 from the Arduino site?

I know this sounds strange, but I would recommend installing the IDE from the Ubuntu repository. It is not just the IDE it installs, but all the avr-gcc and avr-libc files will be upgraded to the debugged versions.

IDE v1.0 on Ubuntu v11.10 works great, if you download v0022 from the repository first. It does for me anyway.

this sounds good. I'll let you know. urk! you say ubuntu 11.10? I'm running 10.10. is it possible that the debugged code is only available for 11.10 ?

best regards, john

I'm not on my Ubuntu box right now. I am being held prisoner by a Windoze box. I imagine all version packages have been upgraded.

I used the Ubuntu "package manager" to install Arduino IDE. It advised me that it was going to upgrade other packages too (avr-gcc and avr-libc). After installation, when I ran it, it showed IDE v0022.

Later, when v1.0 was released, I downloaded it from the Arduino site and ran the arduino shell script from that folder. Works great.

it does seem likely that my ubuntu installation is screwed up. synaptics loads 18 not 22 on 10.10,
so it looks like what i should do is waste the /usr/share/arduiono that’s there, then install 22 then 1.0

it may be that my avr-libraries are also obsolete.

ah well…

I am kinda surprised. Maybe Ubuntu updates only the few most recent releases. As I recall, v0018 doesn't support the mega2560. Wish I could be more help. :frowning:

looks like i need to update Ubuntu to 11.10. nuts.

FYI: Ubuntu 11.10 has a non-kde GUI. Some don't like it. It does take a bit of getting used to. I can adapt to almost anything.

I was about to post about this exact same problem, but I wanted to do some more testing first.

Gentoo Linux, Arduino 1.0. Very simple serial code fails exactly the way you describe - Serial works from PC to Arduino, but Arduino cannot send it back.

Same exact board plugged into a windows PC is able to load the same exact test code and it works fine.

I fixed my problem. Arduino is apparently VERY picky when it comes to the cross-compile environment.

If you use GCC < 4.4, you cannot program for the Arduino Mega 2560. If you use GCC 4.4 <= ver < 4.6.2, you get that serial issue. Only 4.6.2 works as far as I have been able to find (I tried a lot of combinations!)

Additionally, libc MUST be version 1.7.1. Version 1.8.0 deprecates some functions that arduino uses. Binutils needed to be 2.21.1-r1 (2.22 didn’t work for some reason).

In Gentoo, this is a solvable problem. Somebody else posted the same solution, and it’s the same solution I somewhat-independantly came up with:,93672.0.html

I don’t know about ubuntu. Perhaps find those versions of avr-gcc, libc, and binutils in ubuntu?

Fixed. I upgraded Ubuntu from 10.10 to 11.10 and now it works and i can load and run the Mega2560 from Ubuntu. i did go back and reinstall everything item by item on the list of dependencies. It may be that a simple installation of IDE 1.0 will work out of the box in 11.10, while not working in 10.10. I'll never know.

It is also possible to reinstall the Gnome (older) gui in 11.10 but it has a couple of anomalies that cause me problems with another application.

Thanks SurferTim, john - m/v arcadian marathon, fl

Hey down in Marathon! Does m/v mean what I think? I'm a long time yachtie too. Moved from California to Florida by way of the Panama Canal in 1986. Sailboat tho. :slight_smile:

Additionally, libc MUST be version 1.7.1. Version 1.8.0 deprecates some functions that arduino uses.

Some here are already running avr-libc v1.8.0 with Arduino. Requires minimal patching, and those have been reported to the Arduino crew. Hopefully, all that will be fixed in the new IDE release.

The only main deprecated data type in v1.8.0 is "prog_char" in Print.cpp. Replace that with "char PROGMEM", and you are good to go. I think this thread covers it: