-3

Can I make all in one arduino robot? Example - line follower, bluetooth control, sonar sensor,dtmf in one arduino robot just switch to any mode without change the parts.

closed as too broad by Ignacio Vazquez-Abrams, Chris Stratton, Paul, Mattia, Madivad Apr 28 '16 at 11:09

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Sure. Just get a large enough device. – Ignacio Vazquez-Abrams Apr 28 '16 at 3:01
  • Pls tell me how. – Suny Apr 28 '16 at 3:02
  • 2
    @Suny please show some effort of your own. What have you tried? What works, what doesn't work? What do you think that's wrong? What have you observed? What sources have you found? What do/don't you understand? – Paul Apr 28 '16 at 7:31
  • I just want to make a robot with arduino.I want to add line flower,sonar,bluetooth control and dtmf. I want these 4 thing in different 4 switch with one arduino.I want to turn on/off 1/2/3/4 or all feature at the same time without changing parts.I want all of them in same place together but with different switch. – Suny Apr 28 '16 at 8:48
4

Yes, actually it has been done before (multiple times). I, along with some other students did such a project at my school.

https://www.youtube.com/watch?v=GTJQ2VXtmk0 https://www.youtube.com/watch?v=sXXh3Q8WoEM

Materials needed

  • Arduino (or other programmable microcontroller board with voltage regulation)
  • Battery pack (and charger)
  • 2 to 5 line sensors
  • ultrasonic sensor
  • Bluetooth module
  • Robot chassis
  • Atleast two motors (with encoders is nicer, but not neccesary)
  • Motor driving circuitry
  • Switch and emergency stop button

It can be useful to buy a "line follower robot kit"

Connection

This is the connection we used. You're free to make your own adjustments.

enter image description here

Programming

We used a server that (was connected via bluetooth) and has the map and a user-interface. When you press the end-point on the server, it would generate the shortest route, calculate the directions, and send it to the robot.

The robot would then drive until it comes to a junction and then executes the direction command.

I've attached some preview code. It's better to do it yourself, but if you really don't know where to get started, you can try this. You will have to implement the low-level code yourself.

The robot will wait for Bluetooth messages. You can set it to a "direct drive" modus or "line following" modus.

void setup() {
  // put your setup code here, to run once:
  setupBluetooth();
  setupUltrasonicSensor();
  setupMotors();
  setupLinesensors();
  state=waiting;
}

void loop() {
  char receivedCharacter = bluetoothReceiveCharacter();

  switch (state) {
    case waiting:
      switch(receivedCharacter){
        case 'd':
          bluetooth.println("Direct Drive enabled!");
          state = directDrive;
        break;
        case 'l':
          bluetooth.println("Line following enabled!");
          state = following;
          motor1.setSpeed(50);
          motor2.setSpeed(50);
        break;
      }
      break;
    case directDrive:
        directDrive(receivedCharacter);
      break;
    case following:
        followLine(receivedCharacter);
      break;
    default:
      bluetooth.println("STATE ERROR!");
      buzzer.buzz();
      led.blink();
    break;
  }
}

void followLine(){
    long distance = ultrasonicSensor.measureDistance();
    unsigned char lineSensorsPattern = lineSensors.getPattern();

    switch(receivedCharacter){
      case 'X':
        bluetooth.println("Line following disabled! (Now waiting)");
        state = waiting;
      break;
    }

    if(distance > 100 || distance == -1){
      switch(lineSensorsPattern){
        case 0b00000000:
          motor1.setSpeed(0);
          motor2.setSpeed(0);
          bluetooth.println("Following interrupted, lost path!");
          findPath();
        break;
        case 0b00000100:
          motor1.setSpeed(100);
          motor2.setSpeed(100);
          bluetooth.println("Following line, middle sensor on.");
        break;
        case 0b00000100:
          motor1.setSpeed(100);
          motor2.setSpeed(100);
          bluetooth.println("Following line, middle sensor on.");
        break;
        case 0b00000110:
          motor1.setSpeed(70);
          motor2.setSpeed(100);
          bluetooth.println("Following line, middle & right sensor on.");
        break;
        case 0b00001100:
          motor1.setSpeed(100);
          motor2.setSpeed(70);
          bluetooth.println("Following line, middle & left sensor on.");
        break;
        case 0b00000010:
          motor1.setSpeed(0);
          motor2.setSpeed(100);
          bluetooth.println("Following line, right sensor on.");
        break;
        case 0b00001000:
          motor1.setSpeed(100);
          motor2.setSpeed(0);
          bluetooth.println("Following line, left sensor on.");
        break;
      }
    }else{
      bluetooth.println("Following interrupted, obstacle in path!");
    }
}

void directDrive(char receivedCharacter) {
  switch (receivedCharacter) {
    case 'X':
      motor1.setSpeed(0);
      motor2.setSpeed(0);
      state = waiting;
      bluetooth.println("Direct Drive disabled! (Now waiting)");
      break;
    case 'w':
      motor1.setSpeed(motor1.getSpeed()++);
      motor2.setSpeed(motor2.getSpeed()++);
      break;
    case 'a':
      motor1.setSpeed(motor1.getSpeed()++);
      motor2.setSpeed(motor2.getSpeed()--);
      break;
    case 's':
      motor1.setSpeed(motor1.getSpeed()--);
      motor2.setSpeed(motor2.getSpeed()--);
      break;
    case 'd':
      motor1.setSpeed(motor1.getSpeed()--);
      motor2.setSpeed(motor2.getSpeed()++);
      break;
  }
}

My advice

My best advice is to work in iterations. Slowly add more features until you've got the product that you desire. Or develop parts of it individually.

  1. Get a bluetooth link working, send some messages back and forth.
  2. Connect motors to an Arduino and chassis let it drive a pre-programmed path.
  3. Get some line sensors to work (non reflecting black tape!)
  4. Get a ultrasonic sensor to work.
  5. Start combining these! Control the robot over bluetooth. Let the robot follow the lines. Add a breaking when it sees something within range.

As addition/clarification. You could make a button, that increases the state every time you press it. If you then check which state the robot is in, you can make it perform his task for that state.

if(buttonPressed){state++;}
if(state>3){state=0;}

if(state==0){
  //code for DTMF handling
}else if(state==1){
  //code for bluetooth
}else if(state==2){
  //code for sonar
}else if(state==3){
  //code for line sensors
}
  • 1
    I'm sure the OP sill just write "there are compiler errors in your code, can you fix them?", according to the amount of effort he put in the question. And by the way, great answer, even if it is wasted for this question – frarugi87 Apr 28 '16 at 8:13
  • How to without ATMEGA? I want to use only a anduino r3 – Suny Apr 28 '16 at 8:39
  • @Suny the Arduino R3 is an "Atmega328P development board". In our project, we "made our own Arduino". You can easily use the Arduino Uno R3 in your case, it doesn't really matter ;) – Paul Apr 28 '16 at 8:59
  • I just want to make a robot with arduino.I want to add line flower,sonar,bluetooth control and dtmf. I want these 4 thing in different 4 switch with one arduino.I want to turn on/off 1/2/3/4 or all feature at the same time without changing parts.I want all of them in same place together but with different switch – Suny Apr 28 '16 at 9:42
  • I hope u understand. – Suny Apr 28 '16 at 9:45

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