Go Down

Topic: Mega 2560 > Me. (Read 1 time) previous topic - next topic

aaronpbrooks

I must be an idiot.  I just picked up a Mega 2560 for a project I've been piecing together that requires comm with a number of other devices.  Anyway, sketches that work just fine on my Uno, don't work on the Mega.  Everything seems to compile and upload just splendidly, but then things get odd.  Serial comm seems to be working nominally, but I can't get any digital, PWM, or analog ports to work - specifically, I can't even get a single LED to light up (other than one plugged in to pin 13 - but even that I can't control - it only lights up upon reset and serial comm).

Any ideas here?  I must be missing something that's terribly obvious.

johnwasser

Are you doing anything strange like direct port access?

Does the Blink example not blink the on-board LED?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

James C4S


Any ideas here?  I must be missing something that's terribly obvious.

I'm placing bets it is around line 12 or 47 of the code you didn't post.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

aaronpbrooks

I haven't done any port manipulation; only digital and analog write commands.  If I remember correctly (I don't have the board available at the moment to confirm), the on-board LED did work for at least some of the test cases I tried out with it.  I will test again tomorrow, though.

I actually tried the same sketch on two separate Megas, both with failing results, followed by success on an Uno...  If nothing else, it makes me fairly confident that it's something that I'm doing wrong - not a hardware issue as I had initially suspected.

James C4S

Okay. In that case I'm suspecting it is lines 6 or 22 of the code you still haven't posted.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

aaronpbrooks


I'm placing bets it is around line 12 or 47 of the code you didn't post.
[/quote]

Clever...   XD Yeah, I figured that would come up, but I don't think there were even 12 lines of code in total in the digitalWrite or analogWrite sketches I tried (corresponding to the proper pin types).

James C4S

I'm not use to troubleshooting nonexistent code so well.  Obviously it is line 5.  Hard to believe you missed it!
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

aaronpbrooks

I'm sure there will be yet another comment on not posting code here, but is there a distinction beyond calling different pins and tx/rx ports on an Uno and Mega?  If not, shouldn't identical code working properly on one board and not another be an indication that the problem is elsewhere?

AJB2K3

You did install the Mega's drivers and set the board preference to the correct mega did you?
I'm using the mega adk that uses a separate driver config!
Sorry for the noobish post but my knowledge is 10 years out of date!

aaronpbrooks

To be fair, here is an example (I just tried running it again).  This is the example code provided with the IDE under basic > blink.

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
*/


void setup() { 
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);     
}

void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  delay(1000);              // wait for a second
}


I do know that I have the proper board selected (Mega 2560), but I'm not sure about drivers... do you mean bootloader?  If so, that's something I haven't yet ventured into, but I had assumed  it would come preloaded with the correct bootloader.  Or maybe there are some drivers I'm not familiar with?


mellis

Hmm, if blink isn't working there's definitely some issue.  What happens when you try to upload?  What operating system are you on?  Which version of the Arduino software are you using?

aaronpbrooks

Mellis-

Uploading seems to work as expected and completes without throwing any errors.  I'm working on Lion OSX, using Arduino 1.0 at the moment (I'll need to update to 1.0.1 it seems), but I've also tried with 0022.  I'll update to 1.0.1 here and see if there's any magic there.

Go Up