Feedback!

Plant Navigator

Views: 3935 Difficulty: 3 Status: Development
Screen_shot_2012-12-24_at_2.23.54_pm

Light sensors guids this robot towards the light.

Does your bamboo know where its going? Send your hungry plants towards the light so they can photosynthesize some food. Just plop a plant on our light navigator bot and the six light sensors will look for light in all directions. The bot will turn to face the direction with the most light and then drive towards it. Stick a shrub on this robot and see if it finds the sun. Check out our other robots. We consider this bot autonomous, because all the code it uses for navigation is stored on-board in the Atmega168 bot brain.

The PCB

Screen_shot_2012-12-24_at_2.23.54_pm
Bamboo Looks 4 Light was the original name for the plant navigator.

Plant Bot Video

Watch the bot at double speed as she follows those high power LEDs!

Light Navigator Code

This is the arduino code that drives the plant navigator bot's little atmega brain. The function:
int minIndex(int a[], int length){
  int minIndex = 0;
  for (int i = 1; i < numSensors; i++){ 
    if ( a[minIndex] > a[i] ) minIndex = i;
  }
  return minIndex;
}
goes through every one of the 5 light sensors and sees which has the smallest value. The one with the smallest value corresponds to the light sensor receiving the most light. Now depending on which sensor is the minimum there are three possibilities of action. The possibilities are to turn left if the brightest light was to the left, go straight if the bright light was head on, and go to the right if the light was on the right side. This is expressed in the if...else statment below:
 if ( curMin == 0 ){ // go forward we are facing the light
     left.write(85);
     right.write(105); 
  } else if ( curMin == 1 || curMin == 2){
     left.write(105);
     right.write(105);
  } else {
     left.write(80);
     right.write(80 ); 
  }
/* LucidTronix Plant Navigator
 * For tutorial, schematics and explantion see:
 * http://www.lucidtronix.com/tutorials/17
 * this servo robot steers in the brightest direction
 * in effect heading towards the light.
 * Using five photoresistor light sensors arranged in a circle
 * And differential steering on the 2 servo motors.
 */
#include <Servo.h>

const int numSensors = 5;
int lightSensors[numSensors];
const int ledPin = 13;  

Servo left;
Servo right;

int minIndex(int a[], int length){
  int minIndex = 0;
  for (int i = 1; i < numSensors; i++){ 
    if ( a[minIndex] > a[i] ) minIndex = i;
  }
  return minIndex;
}

void setup() {
  Serial.begin(9600);
  left.attach(5);
  right.attach(6); 
}



void loop() {
  for (int i = 0; i < numSensors; i++){
    lightSensors[i] = analogRead(i);
  } 
  int curMin = minIndex(lightSensors, numSensors);
  if ( curMin == 0 ){ // go forward we are facing the light
     left.write(85);
     right.write(105); 
  } else if ( curMin == 1 || curMin == 2){
     left.write(105);
     right.write(105);
  } else {
     left.write(80);
     right.write(80 ); 
  }
}

Parts

Title Description # Cost Link Picture
Servo Motor Continuous rotation servo motor. 2 $13.95 Link 09347-1
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
Photocell Photo resistor Light sensor 16-33KOHM Value: 16 ~ 33 kOhms @ 10 lux 6 $0.8 Link Screen_shot_2012-12-28_at_7.35.43_pm
Crystal CRYSTAL 16.00000 MHZ 20PF SMD Value: 16MHz 1 $0.53 Link Ecs-270-20-3x-en-tr
Resistor RES 10K OHM 1/4W 5% CF MINI Value: 10k 10 $0.08 Link Screen_shot_2012-12-28_at_7.28.15_pm
Permalink: http://lucidtronix.com/tutorials/17
Two proximity sensors help this bot avoid cliffs....
Wall-ter is a wall following robot....
RGB Flashlight, wearable sound art, rainbow lamp....
Servo motor, JPEG camera, and Arduino Leonardo combine to make a panoramic camera....
Control a 120v outlet with a 5V arduino....
Wearable digital compass displays the direction in green LEDs....
Write messages on Liquid Crystal Displays with potentiometers or keyboards....
Arduino-powered spherical camera with 2 Servo Motors and an SD Card....