2
$\begingroup$

I am planning to build robot like irobot Roomba. So cleaning in a spiral pattern is required like the image shown starting from the center:

Spiral

This code is part of my full code which doesn't give me spiral pattern:

void spiralling() {
  for(int i=0;i<=2;i++) {
    digitalWrite(motor1,HIGH);
    digitalWrite(motor2,LOW);
    digitalWrite(motor3,HIGH);
    digitalWrite(motor4,LOW);
    analogWrite(pwm1,180);
    analogWrite(pwm2,80);
    delay(300);
    p=1;
  }
  analogWrite(pwm2,250); 
  delay(150); 
}

So my question is how can I make my bot trace spiral pattern (algorithm?,Logic? to use), as the only way to change the direction is with two wheels on sides.

Is there any code which constantly increases the radius of bot movement from center to radially outwards?

My robot has arduino uno ,l293d motordriver,two geared motors on either sides as shown in image and castor wheel in front:

My robot has arduino uno ,l293d motordriver,two geared motors on either sides as shown in image and castor wheel in front

$\endgroup$
  • $\begingroup$ Let's assume that your wheels don't slip and that you just want the bot to move in a spiral (rather than trace a pattern on the ground). If you want to trace a pattern on the ground, there are very many on-line resources for building a line-following robot. I think the basic approach would be: 1. set the speed of one wheel to a fixed value (call this maximum speed), and the other to zero. 2. while the speed of the "inside" wheel is smaller than the maximum speed, increase it by a small amount, pause, and repeat. Try that out and see how that goes! $\endgroup$ – combo Feb 26 '17 at 3:45
1
$\begingroup$

the code should be like this:

int tourtime=1000; // circle tourtime. it is about intersection areas between each spiral. it should be less than circle time
int increasetime=10; // time for next tour, larger spiral needs more time
int numberofspiral=10; // number of circle
int minspeed=50; // initial speed for spiral. 
int maxspeed=200;// max speed 
void spiralling() {
  digitalWrite(motor1,HIGH);
  digitalWrite(motor2,LOW);
  digitalWrite(motor3,HIGH);
  digitalWrite(motor4,LOW);

  for(int i=0;i<=numberofspiral;i++) {
    analogWrite(pwm1,maxspeed);
    analogWrite(pwm2,minspeed);
    minspeed=minspeed+1;// increase the speed to increase radius
    delay(tourtime);
    tourtime=tourtime+increasetime;// increase the time for scan optimum area
  }
  analogWrite(pwm2,250); 
  delay(150); 
}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.