Go Down

Topic: Mega 2560 can't run "Dimmer" example (Read 2580 times) previous topic - next topic


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.


i am having the same problem? any help?


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.


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.


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?


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  :0


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. XD  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); 

void draw() {
// draw a gradient from black to white
for (int i = 0; i < 256; i++) {
line(i, 0, i, 150);

// write the current X-position of the mouse to the serial port as
// a single byte

I hope this helps.

Go Up