Think...Think...Think...

I have a project that can make a robot go forward, right and left and has a gun turret system(with LED).
I need some ideas on how to improve this model, I'm adding a blue-tooth control soon to make it wireless, but what else can I add to the robot to make it more...cool...interesting...nerdy...etc.

Here is the code

#include <Servo.h>

int LedPin1 = 12;
int LedPin = 13;
int MotorPin1 = 9;
int MotorPin2 = 10;
int servoPin = 6;

Servo VishalServo;

void setup()
{
  digitalWrite(LedPin, HIGH);
  Serial.begin(9600);
  Serial.println("Robotic tank");
  pinMode(LedPin, OUTPUT);
  pinMode(LedPin1, OUTPUT);
  pinMode(MotorPin1, OUTPUT);
  pinMode(MotorPin2, OUTPUT); 
  VishalServo.attach(servoPin);
  VishalServo.writeMicroseconds(1500);
  Serial.println("Wait for 1 second");
  delay(1000);
  Serial.println("You can now give commands");
}

void loop()
{
  while (Serial.available() == 0);
  int val = Serial.read() - '0';
  
  int i = VishalServo.read();
  
  if (val == 2)
  { 
   Serial.println("Robot is On"); 
   digitalWrite(MotorPin1, HIGH);
   digitalWrite(MotorPin2, HIGH);
   delay (500);
   digitalWrite(MotorPin1, LOW);
   digitalWrite(MotorPin2, LOW);
   delay(5); 
  }
  
  if (val == 1)
  {
   Serial.println("Robot is turning left");
   digitalWrite(MotorPin2, HIGH);
   delay(500);
   digitalWrite(MotorPin2, LOW);
   delay(5);
  }
  
  if (val == 3)
  {  
   Serial.println("Robot is turning right");
   digitalWrite(MotorPin1, HIGH);
   delay(500);
   digitalWrite(MotorPin1, LOW);
   delay(5);
  }
  
  if (val == 9)
  {
  Serial.println("Turning right");
  VishalServo.write(i+5);
  delay(5);
  }
  
   if (val == 7)
  {
  Serial.println("Turning left");
  
  if (i >= 165)
  {
    delay(5);
  }
  
  if(i <= 165)
  {
  VishalServo.write(i-5);
  delay(5);
  }
  }
  
   if (val == 5)
  {
   Serial.println("Shoot");
   digitalWrite(LedPin1, HIGH);
   delay(50);
   digitalWrite(LedPin1, LOW);
   delay(5);
  }
  
  if (val == 8)
  {
    Serial.println("Centering");
    VishalServo.writeMicroseconds(1500);
    delay(5);
  }
  
  else
  {
    delay(5); 
  } 
  
}

Any ideas will be appreciated...

Thanks

Hi Vishalapr,

How about a sensor or two, so it can react to the world?

e.g. light, sound, touch.

Regards,
Jim

You could make your constants "const"s.

vishalapr:
I have a project that can make a robot go forward, right and left and has a gun turret system(with LED).
I need some ideas on how to improve this model, I'm adding a blue-tooth control soon to make it wireless, but what else can I add to the robot to make it more...cool...interesting...nerdy...etc.

Adding a gripper with a temperature sensor to fetch a beer out of the fridge that is in the right temperature is a must... :slight_smile:

Infrared transmitter so it can change TV channels for you.

Have you added a sonic range finder yet? It can help your robot avoid obstacles. You can also add a gyro to help the robot go in a straight line, or at least in a fixed direction, I suppose.

liudr:
Have you added a sonic range finder yet? It can help your robot avoid obstacles. You can also add a gyro to help the robot go in a straight line, or at least in a fixed direction, I suppose.

Not to be obnoxious, I just dont want to confuse the OP. Dont you mean a magnetometer, or is there something I am missing?

bilbo:

liudr:
Have you added a sonic range finder yet? It can help your robot avoid obstacles. You can also add a gyro to help the robot go in a straight line, or at least in a fixed direction, I suppose.

Not to be obnoxious, I just dont want to confuse the OP. Dont you mean a magnetometer, or is there something I am missing?

No, I meant a digital gyroscope, which tells directions. A magnetic sensor can do similarly.

Wouldn't a magnetometer be a much more direct way of measuring orientation relative to a fixed point? Gyroscopes measure rate of rotation around the axes which they measure. For going in a fixed direction, i would think a magnetometer would be the best.

An accelerometer and gyroscope assembly tells all orientations you need to know. Your way is another way. I don't see why it has to be much better with a magnetic sensor.

Thanks for the ideas everyone, I am thinking about the tv thing...Please keep posting as many ideas as you can

Its just that for a ground rover robot, an accelerometer + gyro seems like complete overkill just to tell the direction that your bot is pointed.