Serial Communication issues between Max and Arduino
I having some strange and inconsistent issues with some stuff I'm working on. I have an Arduino Mega sending basically on and off information into Max, and Max then uses these as on/offs for toggles (I'm building a kind of interactive DDR for kids). The way I set it up was to have the Ard Serial.write a lowercase letter when a specific pushbutton combination was true, and an uppercase letter when that combo was false( a quick and dirty way to give combinations a unique signature. The thing is that this worked, and really nicely. I have just started building full size hardware, and went back to my proto just to test the code(wrote it back in June), and nothing worked as it had before. I hadn't fooled with the software since. I simplified everything down to try and track the bug, but have had no luck. It seems to come and go.
The Ard code seems solid. Checking the serial window shows exactly what it should. I hooked a message box up the ITOA object, and have gotten all kinds of weird messages. In one instance, it was "P" and "X". In another, it was a stream of what looked like the symbols when you hit a number with shift. Another still was "|". Every so often it will give me an "a" and "A" like it should, but if I close up and restart, it's back to the crazies.
Stuff I've tried:
Cleaned out Max completely and reloaded
Rewrote a very simple Ard code for one button using only "1" and "0" as messages. This worked once, and then the messages reverted to "P" and "X"
My guess is that either something is up with the way I am trying to use Max, or my computer's virtual serial ports are not working right. I am very new to this, so I am at a bit of a loss. I've attached both the Max Patcher and the Arduino Code. If anyone has some helpful ideas I'd love to hear them, and would really appreciate it!
Fiddlesticks, apparently the Ard code can't be uploaded. It's a fairly simple "if these two buttons are pressed, send 'a', if not send 'A' ". Like I said, it all looks great in the serial window.
Normally, the strange letters will come out of serial object if baud rate is wrong.
As Source said, check your baud rates match, also if you have any input on the TX RX pins it may mess up your serial comms. On an Uno these are pins 0 and 1, the Mega has 3 extra serial ports but the USB ones are still 0 and 1.
Try a different USB port if you can't upload, also check you have the right board and ports selected in Arduino IDE
Hey,
Thanks for the quick response. My baud rates are set the same (9600 for both) and I'm not using the extra ports, but thanks for the reminder! The funny thing I discovered this morning is that if I build a fresh patcher, everything works. I close Max, restart it, and everything goes wrong again, unless I re-input the baud rate argument on the serial object. Once I do this, the patcher works again, so it seems like the baud rate is somehow getting reset either on the close of Max or restart.
I'm fairly certain that a message/load bang combo might be a good workaround, but I'd love to know why this is happening to begin with. My understanding is that setting the arguments on the object, ie [serial c 9600] should set them. I checked using the attribute object, and the baud shows at 9600, but obviously isn't. Thinking I need to contact my computer service.
Thanks again for the help!
Serial Object is sometimes acting strange.
I prefer using serial objects with no arguments, loadbanging message like :
port Bluetooth-Modem, baud 9600
That works for me allways, independent of max version.
There is a alternative external for serial object called comport.
It has some advantages, like closing serial port etc.
Yeah, that makes sense. Glad I'm not the only one having this issue. Thanks for the help!