loading

Hi, this is an open source Bluetooth car. It is really reactive and can be controller via an Android app or a Windows program. The Android app is made using the MIT App Inventor 2 so it's really easy to modify; the Windows program is writted in Visual Basic .NET with Visual Studio 2015. The core is an Arduino UNO that receives data from a Sparkfun BlueSMiRF Silver, a small $ 24.95 Bluetooth receiver.

It's easy to build: anything you need is a pack of Meccano®, a servo motor, the Arduino and an H-bridge (L6203, datasheet).

Let's build it!

You can download all the files in my website at the end of the page!

Presented at Maker Faire Rome with FabLab Frosinone! YouTube video

Step 1: The App

The first things are the Arduino firmware and the Android app.

As you can see in the screenshots, develop an Android app with App Inventor 2 it's really easy! You must add the components on the image of the phone and then program them with small blocks. Visit the App Inventor Gallery or download the APK from my website.

For Windows is a bit challenging: Visual Basic .NET isn't really difficult but this time you need a lot of tutorials to create this program from zero. The difference between VB and AI2 is the code: as for Android, in Visual Basic we have to put the components on the screen, then write the code, not blocks. You do not have VS? Look at this preview on my site!

Step 2: Arduino Sketch

For the Arduino, it's necessary a small sketch that only receives the data, turns on the motor (forwards and backwards) and every 300 ms checks the distance from the wall:

void loop() {
  if (Serial.available()) {
    val = Serial.parseInt();
    
    if (val == 21) {         //Off
      goTo(0, 0);
      offOn = false;
      
    } else if (val < 20) {
      myservo.write(constrain(map(val, 0, 20, 140, 40), 40, 140));
      
    } else if (val == 22) {   //LED On
      digitalWrite(LED, HIGH);
      
    } else if (val == 23) {   //LED Off
      digitalWrite(LED, LOW);
      
    } else if ((val >= 1500) && (val <= 1755)) {    //Backwards
      val = val - 1500;
      goTo(2, val);
      offOn = true;
      
    } else if ((val >= 1000) && (val <= 1255)) {    //On
      val = val - 1000;
      goTo(1, val);
      offOn = true;
    }
  }
  unsigned long now = millis();
  if (now - lastime >= 300) {   //Check the distance every 300 ms
    lastime = now;
    if (distanza() < 40) {      //Near a wall...
      delay(30);
      unsigned long distance = distanza();
      if (distance < 40) {      //Check another time the distance (to be sure...)
        if (offOn == true) {    //If turned on, the car go backwards
          goTo(2, 210);
        }
        byte pulses = map(distance, 2, 40, 20, 1);
        unsigned int msPerPulse = 1000 / (pulses * 2);
        for (byte index = 1; index <= pulses; index++) {//Play a frequency based on the distance
          tone(12, 2000);
          delay(msPerPulse);
          noTone(12);
          delay(msPerPulse);
        }
        if (offOn == true) {
          goTo(0, 0);
          delay(100);
        }
      }
    }
  }
}
long distanza() {   //Proximity
  long distanza;
  digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  distanza = pulseIn(echo, HIGH);
  distanza = distanza / 58;
  Serial.println(distanza);
  return distanza;
}
void goTo(byte dir, byte Speed) {   //Go backwards and forwards
  
  if (dir == 1) {
    analogWrite(BMpin, 0);
    digitalWrite(enablePin, HIGH);
    analogWrite(Mpin, Speed);
    
  } else if (dir == 2) {
    analogWrite(Mpin, 0);
    digitalWrite(enablePin, HIGH);
    analogWrite(BMpin, Speed);
    
  } else if (dir == 0) {
    digitalWrite(enablePin, LOW);
    analogWrite(Mpin, 0);
    analogWrite(BMpin, 0);
  }
}

Step 3: A Lot of Pacience

Do you like the Meccano brand?

Look at the photos...

Another difficult thing is the steering wheel...

Step 4: Electrical Connections

The circuit is big but easy:

I placed the driver on a DIY shield, with a buzzer, a reset button and some headers for inputs and outputs:

  • Input/outputs
    • Bluetooth modem
    • Ultrasonic ranger
  • Outputs
    • Servo motor
    • Buzzer
    • Motor controller
    • Lamp (observe the video)

To drive the 2,7A 9V motor of the Meccano pack I used an H-bridge called L6203 (datasheet). The servo motor I used is really powerful but need 6V, so I added an LM317 to my DIY shield.

When the car is near a wall starts to play a frequency repeatedly like a real car: you can see this feature in the video.

<p>Awesome Arduino car. </p>

About This Instructable

3,434views

73favorites

License:

More by SquareBoot:Android edition for JustAPendulum JustAPendulum: open source electronic pendulum RoverBluetooth: Arduino-based Bluetooth car 
Add instructable to: