[edit]I've got it compiling OK using Processing 1.0.3 - you're not using the Arduino IDE to compile it, are you? [edit]Yes, I think you are. The sketch is written in Processing (Java) meant to run on a PC, not an Arduino[/edit][/edit]
The Processing application talks to the Arduino using the serial port. The code you are trying to upload to the Arduino is NOT the code that goes on the Arduino.
You need to compile and run that code in Processing, and compile the correct code for the Arduino.
You’re missing a large part of the code posted.
All of the “#define SETSPEED”, etc are missing from your code, and there’s a ton of missing “}”
Just get the code from the single line, and go through it methodically.
Don’t discard stuff that contains “#” or “}”
There’s no need to set the pinMode for a servo pin, because that is done automatically by the library.
The code for “checking” the three “A” characters is rubbish because the comparisons are assignments, so will always be true (unlees a “nul” character is received).
/* * Arduino Controlled Web Connected Robot (WEBB) - Serial Host
* For more details visit: http://www.oomlout.com/serb
* * Behaviour: The Arduino listens to its Serial port for a command
* in format 254, 88, 88, (COMMAND), (TIME)
* Supported Commands - 'F' - 70 - Forward
* 'B' - 66 - Backward
* 'L' - 76 - Left
* 'R' - 82 - Right
* 'S' - 83 - Speed
* 'X' - 88 - SetSpeedLeft
* 'Y' - 89 - SetSpeedRight
* 'C' - 67 - Stop
* Supported Times - 0 - 255 (0 to 25.5 Seconds) value * 100 milliseconds
*
* Wiring: Right Servo Signal - pin 9
* Left Servo Signal - pin 10
* * License: This work is licenced under the Creative Commons
* Attribution-Share Alike 3.0 Unported License. To
* view a copy of this licence, visit
* http://creativecommons.org/licenses/by-sa/3.0/
* or send a letter to Creative Commons, 171 Second
* Street, Suite 300, San Francisco, California 94105,
* USA.
*
*/
//-------------------------------------------------------------------------
//START OF ARDUINO SERIAL SERVER PREAMBLE
//Defining constants corresponding to each command (also the ascii code number)
#define FORWARD 70 //F
#define BACKWARD 66 //B
#define LEFT 76 //L
#define RIGHT 82 //R
#define SETSPEED 83 //S
#define STOP 67 //C
#define SETSPEEDLEFT 88 //X
#define SETSPEEDRIGHT 89 //Y
/*The three check bytes (used to keep the robot from responding to random serial
*data) currently "AAA" */
#define checkByte1 65 // "A"
#define checkByte2 65 // "A"
#define checkByte3 65 // "A"
//--------------------------------------------------------------------------
// START OF ARDUINO CONTROLLED SERVO ROBOT (SERB) PREAMBLE
#include <Servo.h>
#define LEFTSERVOPIN 10 //The pin the left servo is connected to
#define RIGHTSERVOPIN 9 //The pin the right servo is connected to
Servo leftServo;
Servo rightServo;
int leftSpeed = 50; //holds the speed of the robots leftServo
//a percentage between 0 and 100
int rightSpeed = 100;
//holds the speed of the robots rightServo
//a percentage between 0 and 100
// END OF ARDUINO CONTROLLED SERVO ROBOT (SERB) PREAMBLE
//--------------------------------------------------------------------------
//Gets everything up and running
void setup()
{
Serial.begin(9600); //Starts the serial port
serbSetup(); //sets the state of all neccesary
//pins and adds servos to your sketch
}
//The main program loop
void loop()
{
serbPollSerialPort(); //continuously looks to the serial port
//if there is data it processes it
}
This whole thing looks familiar to me - I seem to recall converting that “one line monstrosity” into something approaching reality a few months ago for someone else on this forum…
He probably meant "11th Grade" - which in America (not sure in other areas?) is called "Junior Year" in high school. Typically, schools are divided into primary - K-6th, secondary - or junior high - 7th-8th, and High School, 9th-12th grade levels - sometimes schools combine certain levels, depending on state and district; but typically, there are 12 grade levels in school (12 years), starting at roughly age 5, so when you graduate from high school (to continue to college, university, tech school, or workforce), you are around 17-18 years of age; so this individual is probably 16-17 years old (maybe 14 or 15, if he/she skipped grades due to academic ability or other reasons).
I will say this much - he or she better be on a phone texting their BFF JILL (and/or had english as a second language) when they posted that...
If english is their first language, and they were typing on a regular computer keyboard, they have no excuse (assuming their age is near what I posted), and their teachers should be fired, their parents chastised, and they should be ashamed, and made to repeat a grade or two...
when i upload the code to arduino , the servo starts to rotate clockwise and when i open the serb robot pc software (which controls arduino) its the same but when i click the forword button the servo is speeds up . all the direction is working but it is not staying still.
how can i make it stand still ?
if you are not getting an idea , i will post a video
ok
The servos are supposed to be stopped when you command them to 90 degrees, but depending on how they were modified, this may be off a little.
Two ways to fix it: experimentation to find what 'angle' stops them, or simply 'detach' them when you want to stop, then re-attach when you want to move
Something to keep in mind; in the thread that I posted, you will notice that the original poster in that thread said he had to make a couple of small changes to get it to work properly, but he did -not- post what those changes were; also, there was a correction posted by another member of these forums indicating some issues with comparison vs value assignment. These issues and differences may explain why you are having issues. You should review these, and perhaps see if you can get into contact with the OP of that thread I posted to find out how he got his to work. Then, when you know things are working OK - please post the changed/updated code into this thread (and perhaps into the other thread as well), so that in the future, others won't have this issue...