Let's Make Robots!

RMOAR - On construction

It will follow objects with certain colors and in its way to the object it will avoid any obstacle and it is also remote monitored by a pc (it will have and rc mode)

Hello to everyone this is my first robot here in LMR but i haven't finished it yet .

I call RMOAR because its letter is one of its functions it means : Remote Monitored Obstacle Avoidance Robot

Its basic function was to avoid every obstacle in his way  but then i decided to remake in order to follow objects with a certain

color and in his way to the object he will also avoid any obstacle.

 

And i have some photos of it in its current state and some from the first states of it.

 

I wrote some code but i dont think that its goin to work and i need some help in order to improve it.

 

 

(UPDATE: 21/2/11)Here is the new code I made:

#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;
int V1,V2,D1,D2;
int sensorPin1 = 5;
int sensorPin2 = 4;
int servoL = 9;
int servoR = 10;
int servoScn = 11;
int ledPin = 13;    
int sensorValue1 = 0; 
int sensorValue2 = 0;
void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPin1,INPUT);
  pinMode(sensorPin2,INPUT);
  pinMode(servoL,OUTPUT);
  pinMode(servoR,OUTPUT);
  pinMode(servoScn,OUTPUT);
  servo1.attach(servoL);
  servo2.attach(servoR);
  servo3.attach(servoScn);
  Serial.begin(9600);
 
}

void loop() {
  Schfobj();
  while(Schfobj() == 0){
    moveForward(100);
    if(Schfobj() != 0){
      continue;
    }
  }
  if(Schfobj() == 1){
     moveRight(170,2500);
  }
  if(Schfobj() == 2){
     moveLeft(170,2500);
  }
  if(Schfobj() == 3){
   moveBackward(170,2500);
  }
  

}

int Schfobj() {
   for(int i = 0; i < 180; i = i + 1){
      V1 = analogRead(sensorPin1);   
      V2 = analogRead(sensorPin2);   
      D1 = (6787 / (V1 - 3)) - 4;
      D2 = (6787 / (V2 - 3)) - 4;
      servo3.write(i);
      delay(50);
      Serial.print("Distance 1 : " + D1);
      Serial.println(" Distance 2 : " + D2);
      if(i <= 90 && (D1 < 15 || D2 < 15)){
         return 1;
      }
      else if(i >= 180 && (D1 < 15 || D2 < 15)){
         return 2;
      }
      else if( i == 90 && (D1  < 15 || D2 < 15)){
         return 3;
      }
      else {
         return 0;
      }
   }
}
void moveLeft(int Speed , int Delay){
      servo1.write(Speed - 91);
      delay(Delay);
      servo2.write(Speed);
      delay(Delay);
}
void moveRight(int Speed,int Delay){
      servo1.write(Speed);
      delay(Delay);
      servo2.write(Speed - 91);
      delay(Delay);
}
void moveForwardd(int Speed,int Delay){
      servo1.write(Speed);
      delay(Delay);
      servo2.write(Speed);
      delay(Delay);
}
void moveBackward(int Speed,int Delay){
      servo1.write(Speed - 91);
      delay(Delay);
      servo2.write(Speed - 91);
      delay(Delay);
}
void moveForward(int Speed){
      servo1.write(Speed);
      servo2.write(Speed);
     
}

It passes the Compile but if anyone can test it for logical mistakes it could be helpfull.

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Is that the metal shell of a CD/DVD drive?

Well in any case it looks awesome.

Yes it is.I started building it with a cd/dvd case but it was too high so I changed it and now Im using the one on the photos.

Well I think its cool how i have seen robots built out of everyday material like a CD/DVD drive case and so on. Awesome robot. It has inspired me.

Hello flokos, I wondered what piece of code your using to communicate between the colorPAL and Arduino. I recently bought a colorPAL for use with my Arduino but can't get anything working. Is there a chance you could upload what your using to help me?

   Thanks. goatboy

the reasons are below (othe members replies) and i havent get colorPal work yet but if il make something il give you a copy.

These pictures looking like I see the world after the 15th beer :)

Can you clean the lens of your camera?

I can only retake the last 2 photographs is this ok ?

which pictures ?the last two?

all --- and I had no beer till now. See this nobody else?

Also check out this camera. Not a great one, but cheap, and readable by an Arduino.