Pages: [1]   Go Down
Author Topic: Mega 2560 can't run "Dimmer" example  (Read 1257 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I run "Dimmer" example with Mega 2560, but it can't receive or response to the serial data that is sent from processing program. I have UNO, it communicate with processing progarm propably. Any special setup is needed for Mega 2560? Running "Fade", "Digital read serial" example with Mega 2560 are ok, so it should not be the problem of downloading or pin failure. Please help.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am having the same problem? any help?
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It might be that the Processing program starts transmitting too soon and so the bootloader on the Mega 2560 never times out (and starts the Dimmer sketch).  Try adding a delay() to the end of the setup() function in the Processing program.  Or check, in the Processing program, that millis() > 5000 (or so) in order to send data over the serial port.
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 32
Posts: 1211
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, this is the same problem I have reported, too, and for a while I've given up. Thought that hordes of (un)happy Mega2650 owners by now would have provoked Processing to fix their Serial - or tell us about a new driver. Interesting that it works with a UNO, it too uses the new-USB/Serial chip/driver, right?

Seems not so, yet.

I tried the delay - makes no difference.
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 32
Posts: 1211
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

twwong: Can you try my Arduino/Processing program pair from this post on both your 2560 and UNO and tell us how much/little works, in particular if it is only in one direction?
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 170
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone here was lucky enough to find a solution?
If not, I find this to be quite crazy that the Mega and processing simply do not perform well together and no one has addressed this problem  smiley-mad
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just bought my Mega 2560 from Radio Shack yesterday and was going thru the examples today and stumbled upon the Dimmer sample.  I downloaded Processing and played around with that for a bit and then went to run the Dimmer and came upon the same issue reported above.  I did some Googling and it seems to have been a common problem for at least a couple of years and no one seemed to find an answer.

Well, after an hour or so trying various things, I stumbled upon the answer. smiley-lol  I was messing around with the DOS MODE command and noticed the options for dtr=on|off|hs.  That got me thinking that maybe the issue is something to do with the handshaking.  So I looked thru the Processing folder and found Serial.java and inside it I noticed the function setDTR. 

So I went back to the Dimmer code and added port.setDTR(true); but it didn't work.  But then I remembered reading another post about adding a delay, so I added a 500ms delay before and after and voila!  It worked!

The funny thing is if I lower either delay from before or after the setDTR it doesn't work, so it seems it needs to be at least 500ms.  Here is my revised Dimmer code for Processing:
...
 port = new Serial(this, "COM3", 9600); 
 delay(500);
 port.setDTR(true);
 delay(500);
 
}
 
 void draw() {
 // draw a gradient from black to white
 for (int i = 0; i < 256; i++) {
 stroke(i);
 line(i, 0, i, 150);
 }
 
 // write the current X-position of the mouse to the serial port as
 // a single byte
 port.write(mouseX);
 }

I hope this helps.
Logged

Pages: [1]   Go Up
Jump to: