Jerky BOEbot
I'm using the Javelin stamp on the BOEbot and the project was partially successful, except for the fact that it doesn't move at any sort of consistent speed.· It moves for a quarter of a second, and is idle for a half a second. Please tell me what is wrong with my program.· I need the help.
My code is as follows
<code>
import stamp.core.*;
public class PathFinder {
//· CPU.pin5 = Right Whisker, CPU.pin7 = Left Whisker
//· CPU.pin12 = Right Wheel, CPU.pin13 = Left Wheel
· public static void main() {
··· while(true) {
····· if(!CPU.readPin(CPU.pin5)){
······· if(!CPU.readPin(CPU.pin7)) {
········· CPU.pulseOut(1400, CPU.pin12);
········· CPU.pulseOut(100, CPU.pin13);
········· CPU.delay(1400);
······· }
······· else {
········· CPU.pulseOut(1400, CPU.pin12);
········· CPU.pulseOut(1400, CPU.pin13);
········· CPU.delay(100);
······· }
····· }
····· else { if(!CPU.readPin(CPU.pin7)) {
······· CPU.pulseOut(100, CPU.pin12);
······· CPU.pulseOut(100, CPU.pin13);
······· CPU.delay(2700);
····· }
····· else {
······· CPU.pulseOut(100, CPU.pin12);
······· CPU.pulseOut(1400, CPU.pin13);
······· CPU.delay(1400);
····· }}
··· }
· }
}
</code>
My code is as follows
<code>
import stamp.core.*;
public class PathFinder {
//· CPU.pin5 = Right Whisker, CPU.pin7 = Left Whisker
//· CPU.pin12 = Right Wheel, CPU.pin13 = Left Wheel
· public static void main() {
··· while(true) {
····· if(!CPU.readPin(CPU.pin5)){
······· if(!CPU.readPin(CPU.pin7)) {
········· CPU.pulseOut(1400, CPU.pin12);
········· CPU.pulseOut(100, CPU.pin13);
········· CPU.delay(1400);
······· }
······· else {
········· CPU.pulseOut(1400, CPU.pin12);
········· CPU.pulseOut(1400, CPU.pin13);
········· CPU.delay(100);
······· }
····· }
····· else { if(!CPU.readPin(CPU.pin7)) {
······· CPU.pulseOut(100, CPU.pin12);
······· CPU.pulseOut(100, CPU.pin13);
······· CPU.delay(2700);
····· }
····· else {
······· CPU.pulseOut(100, CPU.pin12);
······· CPU.pulseOut(1400, CPU.pin13);
······· CPU.delay(1400);
····· }}
··· }
· }
}
</code>
Comments
The first argument of left_wheel.update(); changes the speed & direction, and just leave the second argument there.