148
148
Controlling Motor Speed
●
Enter the program to the right. This program
generates a PWM signal to the motor. Only one
side needs a PWM signal. The other is set to 0
so no PWM signal is present.
●
The code sets the PWM signal to 255 which is
100% duty cycle meaning it is on all the time.
This is the same as
digitalWrite()
function.
●
Run the code and see which direction the robot
drifts.
●
Reduce the value for the opposite direction by
10 and try again. Keep adjusting until the robot
drives relatively straight. It won't be perfect.
●
The
analogWrite()
functions can replace
the
digitalWrite()
functions in the motion
functions.
void setup()
{
pinMode(6,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}
void loop()
{
analogWrite(6,255);
analogWrite(9,0);
analogWrite(10,255);
analogWrite(11,0);
delay(5000);
analogWrite(6,0);
analogWrite(10,0);
delay(2000);
}
Summary of Contents for StenBOT Rover Kit
Page 1: ...1 StenBOT Rover Kit Stensat Group LLC Copyright 2013 ...
Page 4: ...4 Overview ...
Page 22: ...22 22 Assembly ...
Page 58: ...58 58 Processor Board and Arduino Software ...
Page 118: ...118 118 Completing The Robot Motion ...
Page 138: ...138 138 Digital Signal Connections ...
Page 166: ...166 166 Remote Control ...