Sketch problem with BOE and Arduino Shield Bot
druid001
Posts: 2
Just started the BOE Arduino robot project. I'm still in the first chapter "Your Shield Bot's Brain" learning the programming. I'm at the sketch in Chap 3 called TestServoSpeed. When I run the sketch everything happens except...the wheel doesn't turn!. I'm posting my sketch:
#include <Servo.h>
Servo servoLeft;
Servo servoRight;
void setup()
{
tone(4, 3000, 1000);
delay(1000);
Serial.begin(9600);
servoLeft.attach(13);
}
void loop()
{
for(int pulseWidth=1375; pulseWidth<=1625; pulseWidth+=25)
{
Serial.print("pulseWidth= ");
Serial.println(pulseWidth);
Serial.println("Press a key and click");
Serial.println("Send to start servo...");
while(Serial.available() == 0);
Serial.read();
Serial.println("Running...");
servoLeft.writeMicroseconds(pulseWidth);
delay(6000);
servoLeft.writeMicroseconds(1500);
}
}
I even copy\pasted the one in the tutorial with the same outcome. Can anyone see what is wrong with the sketch? Unfortunately there doesn't seem to be a direct way to ask about this, so I've come to the forums. Thanks.
#include <Servo.h>
Servo servoLeft;
Servo servoRight;
void setup()
{
tone(4, 3000, 1000);
delay(1000);
Serial.begin(9600);
servoLeft.attach(13);
}
void loop()
{
for(int pulseWidth=1375; pulseWidth<=1625; pulseWidth+=25)
{
Serial.print("pulseWidth= ");
Serial.println(pulseWidth);
Serial.println("Press a key and click");
Serial.println("Send to start servo...");
while(Serial.available() == 0);
Serial.read();
Serial.println("Running...");
servoLeft.writeMicroseconds(pulseWidth);
delay(6000);
servoLeft.writeMicroseconds(1500);
}
}
I even copy\pasted the one in the tutorial with the same outcome. Can anyone see what is wrong with the sketch? Unfortunately there doesn't seem to be a direct way to ask about this, so I've come to the forums. Thanks.
Comments
Thanks for letting us know. We've all done something like this. I'm glad you let us know you figured out the problem even if it was something simple.
While this might not be the best place to get help with Arduino code, you are very welcome to ask your Arduino coding questions here. Several of us use the Arduino and may be able to help with your questions.
Next time you post code, it will help us read it if you use code tags.
[noparse] [/noparse]
The above will show up as:
Without code tags the forum software removes indentations which destroys the formatting of the code.
BTW, Welcome to the forum.