Robotics Code Error. Help needed

Hello, I'm new here at the arduino forum :slight_smile: and I came here to ask for a little help from the arduino community.

Hooked up to my Arduino Uno is:
Ardumoto controlling 2 hobby motors
Nokia 5110 LCD Screen

And recently, my code has been malfunctioning to drive the motors, the lcd still works though. :grin:

First Error
In order to controll the robot, I use the serial monitor to controll the motors and to put text onto the lcd.
I wrote up some code in processing 1.2 to drive the motors using touchOSC on an iphone.
And Neither of that is working right now. Previously, I've had it run perfectly, with four buttons to controll the directon and a fader to controll pwm, but now its not working.
Well, the command RB and FB, which is for commanding the B Motor to go in Reverse and Forwards, works fine.

Maybe something got unplugged I'm not sure, but I also would some help optimizing the code, (because I know it could be done with a lot less code than I already have), and fixing the error that keeps happening.

The Second Error
When the arduino speaks with the serial monitor, it tells the user how to command the Robot based on the code in my arduino, but after I tell it to go into the Motor program that drives the motor, I have to close it in order to use the processing code. That all works fine and the motor program keeps running untill I run processing, then the arduino reboots and it needs the motor command again. How should I go about doing this. My code will be attached down at the bottom.

RCP.pde (Arduino Code) Short for Robotics Coding Platform
Code.pde (Proccessing Code)
Layout.touchosc(iPhone TouchOSC Layout)

One more thing, I am using Windows 7 to run arduino IDE and Processing, but I could switch over to ubuntu if I needed to, and or to try to fix the problem. I've commented the code a lot, so feel free to comment so I can see what you edited or fixed, that way I can figure out how to improve once the code has been changed.

Thanks,
Shawn :grin:

RCP.pde (16.1 KB)

Code.pde (1.73 KB)

Layout.touchosc (673 Bytes)

When the arduino speaks with the serial monitor, it tells the user how to command the Robot based on the code in my arduino, but after I tell it to go into the Motor program that drives the motor, I have to close it in order to use the processing code.

Why are you using the Serial Monitor to display instructions to the user, when the Processing application is perfectly capable of displaying the instructions?

Making Processing display the instructions would eliminate the need to close the serial monitor, which resets the Arduino, and to open the serial port again (in Processing) which also resets the Arduino.

Well, the command RB and FB, which is for commanding the B Motor to go in Reverse and Forwards, works fine.

If some commands work fine, then it most likely is NOT a software issue. Unless it is the dreaded "all I changed was" bug that is biting you. If so, then the solution is pretty obvious. Change it back.

One more thing, I am using Windows 7 to run arduino IDE and Processing

Win 7 is not really compatible with TouchOSC. On the other hand, Ubuntu isn't either. Time to pay a visit to the Mac store, I think. Won't be a cheap visit, either.

I actually fixed the problem with processing, In the setup procedure, I added port.write("Motors.");, to put it into that mode.

I actually had no idea processing could display a user interface. Could you please link me to a tutorial for that?
I haven't changed anything in the code, but in proccessing I realised I hadn't changed the line end from "#" back to ".", so TouchOSC was fixed.The other motor probally just got disconnected or the soder joint broke. Yeah, I realised that when a lot of errors, with touchosc and Oscp5 library in processing, kept occuring the first time I tried it.

A mac would be nice to fix the problems, maybe I'll use osx86 on my pc or laptop. Hell, I could put a mac mini or Apple TV first gen, it can run osx, on the robot itself to deal with wireless and processing, maybe it could replace the arduino lol. Too bad they're wicked expensive, could a non-intel mac run arduino and proccessing? They cost A LOT less than the newer macs. $1,000 vs $300

Have you taken a look at the code? I have quite a lot of code and I was hoping someone could help me minimize it or make it more efficient, aka, the delays, or the text input and deciphering.

You sound like an arduino pro, you really know your stuff.

Thanks for the information