Shop OBEX P1 Docs P2 Docs Learn Events
Jerky BOEbot — Parallax Forums

Jerky BOEbot

flashbotflashbot Posts: 1
edited 2007-01-05 11:17 in General Discussion
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>

Comments

  • Robot FreakRobot Freak Posts: 168
    edited 2007-01-05 11:17
    You better use PWM objects for servo control.
    static PWM right_wheel = new PWM(CPU.pin12,173,2304);
    static PWM left_wheel = new PWM(CPU.pin13,173,2304);
    while (true) {
      left_wheel.update(130,2304);
      right_wheel.update(220,2304);
    }
    
    


    The first argument of left_wheel.update(); changes the speed & direction, and just leave the second argument there.
Sign In or Register to comment.