Feedback!

Wall-ter

Views: 2013 Difficulty: 3 Status: Development
Screen_shot_2013-02-03_at_3.16.26_pm

Wall-ter is a wall following robot.

Using 3 proximity sensors Wall-ter senses walls. Then he follows them! A few simple rules for how wall-ter moves combine into a complex emergent behavior. Corners are always tricky as you may see in the video below. The three proximity sensors are available at pololu, they cost $6.95 and give a 0 signal when something is near them and 1 if not. Hook them up to any general purpose I/O pin set for reading.

Heads-Up Wallter

Screen_shot_2012-12-21_at_6.46.38_pm
Wall-ters 3 proximity sensors are strategically located so that walls will be found and followed.

Video

Watch wall-ter roll! He finds walls and follows them. He tries not to crash into them. Corners can be tricky as the video shows.

Arduino Code for Wall Following

This code assumes there are 3 digital (binary) proximity sensors arranged with two pointing to the left but a different distances and one sensor pointing forward with a slight inclination towards the left side. So 3 sensors with 2 possible values for each sensor, how many distinct readings can we have? 2 to the 3 or 8. So here is the code that dictates what to do in each of the 8 possible situations:
if (fwdIn == LOW && midIn == LOW && leftIn == LOW) {
    go_backward();
  } 
  else if (fwdIn == LOW && midIn == LOW && leftIn == HIGH ) {
    turn_right();
  }
  else if (fwdIn == LOW && midIn == HIGH && leftIn == LOW ) {
    stay();
 } 
 else if (fwdIn == LOW && midIn == HIGH && leftIn == HIGH ) {
   turn_right();
 } 
 else if (fwdIn == HIGH && midIn == LOW && leftIn == LOW ) {
   turn_right();
 } 
 else if (fwdIn == HIGH && midIn == LOW && leftIn == HIGH ) {
   go_forward();
   wall_timer = millis();
 } 
 else if (fwdIn == HIGH && midIn == HIGH && leftIn == LOW ) {
   go_forward(); 
   wall_timer = millis();
 } 
 else if (fwdIn == HIGH && midIn == HIGH && leftIn == HIGH ) {
   if( millis() - wall_timer > 1500 ) go_forward(); 
   else turn_left();
  } 
}
Each of those simple instructions carried out when the sensors are activated in a certain way adds up to a more simple elegant behavior. This robot seems to follow walls. This is a small example of emergence, here's a little example of emergence from MIT exploring emergence.
/* LucidTronix Wall Follower
 * autonomous robot
 * 3 proximity sensors 
 * Details pictures, explanation at:
 * http://www.lucidtronix.com/tutorials/5
 */
#include <Servo.h>  
Servo right;
Servo left;

int fwdSensor = 0;
int midSensor = 1;
int leftSensor = 2;
int high_pwm = 110;
int low_pwm = 75;
boolean wall_near = false;
unsigned int wall_timer = 0;

void setup() {
  
  right.attach(6);
  left.attach(5);
  
  pinMode(fwdSensor, INPUT);
  pinMode(leftSensor, INPUT);
  pinMode(midSensor,INPUT);

}


void loop() {
  int leftIn = digitalRead(leftSensor);
  int midIn = digitalRead(midSensor);
  int fwdIn = digitalRead(fwdSensor);
  if (fwdIn == LOW && midIn == LOW && leftIn == LOW) {
    go_backward();
  } 
  else if (fwdIn == LOW && midIn == LOW && leftIn == HIGH ) {
    turn_right();
  }
  else if (fwdIn == LOW && midIn == HIGH && leftIn == LOW ) {
    stay();
 } 
 else if (fwdIn == LOW && midIn == HIGH && leftIn == HIGH ) {
   turn_right();
 } 
 else if (fwdIn == HIGH && midIn == LOW && leftIn == LOW ) {
   turn_right();
 } 
 else if (fwdIn == HIGH && midIn == LOW && leftIn == HIGH ) {
   go_forward();
   wall_timer = millis();
 } 
 else if (fwdIn == HIGH && midIn == HIGH && leftIn == LOW ) {
   go_forward(); 
   wall_timer = millis();
 } 
 else if (fwdIn == HIGH && midIn == HIGH && leftIn == HIGH ) {
   if( millis() - wall_timer > 1500 ) go_forward(); 
   else turn_left();
  } 
}
void turn_left(){
  left.write( high_pwm);   
  right.write( high_pwm );
  
}
void turn_right(){
  left.write( low_pwm );
  right.write (low_pwm );
}
void go_forward(){
  left.write(high_pwm);   
  right.write( low_pwm );
}
void go_backward(){
  left.write(low_pwm);   
  right.write( high_pwm );
}
void stay(){
  left.write( 90 );   
  right.write( 90 ); 
}

Parts

Title Description # Cost Link Picture
Servo Motor Continuous rotation servo motor. 2 $13.95 Link 09347-1
Proximity Sensor Digital proximity sensor. 5v Value: 5v 3 $6.95 Link 0j1178.600
Servo Wheel Wheel that attaches easily to servo motors. 2 $4.0 Link Servowheel_lrg
ATMEGA168A-AU IC MCU AVR 16K FLASH 32TQFP Value: 1.8 V ~ 5.5 V 20MHz 1 $2.43 Link Screen_shot_2012-12-28_at_7.31.53_pm
Permalink: http://lucidtronix.com/tutorials/5
Wall-ter is a wall following robot....
Light sensors guids this robot towards the light....
Servo motor, JPEG camera, and Arduino Leonardo combine to make a panoramic camera....
Rainbow flower necklace using the TLC5940....
Think of it like a shift register for Pulse Width Modulation (PWM)....
Control a 120v outlet with a 5V arduino....
Write messages on Liquid Crystal Displays with potentiometers or keyboards....
This L293D Stepper motor controller lets you precisely control a stepper motor with just two signal l...