Arduino robot kit – Bluetooth Remote Control

The Amarino app mentioned used in the previous post translates the sensor inputs of an Android phone ( and other events such as SMS messages) into messages sent to the Arduino via Bluetooth. In this post, I will use the orientation sensor on my phone to drive the Arduino Robot.

The orientation sensor on the Andriod platform provides yaw, pitch, and roll values of a device relative to the earth’s frame of reference (specifically, magnetic north). For more information see here. To remotely control the Robot, you can use two of the three values to (e.g. pitch and roll) to move the Robot forward and backward or right and left. I have created this Sketch to take advantage of this sensor and here is the procedure without much explanation, for now.

  1. Remove the Bluetooth module, attach the USB cable and upload the sketch provided above
  2. remove the USB cable and re-attach the BT module
  3. On the Android phone, use the Amarino app as described in the previous post, remove any events used before then add the Orientation Event. The events get a unique identifier based on the order they are added to the device, so the Orientation event should have ID=”A”
  4. Make sure sure that the app is connected to the BT and the event is enabled
  5. The Robot should move by changing the pitch and roll of the phone and stop when the phone is leveled horizontally

Have Fun!

3 thoughts on “Arduino robot kit – Bluetooth Remote Control

  1. maen Post author

    I suggest to try the basics first. Use only two motors, not four, and use the sketch in the previous comment.
    I also want to point out that the analogWrite() function takes values from 0 to 255 where 255 generates 100% duty cycle (full power to motor).
    The Motor library accepts values from 0 to 100 where 50 maps to 127 and 100 maps to 255. So, if you are using the Motor library function onFwd(), using values higher than 100 will result in the higher bits ignored and the output to the motor will be smaller actually. The following Sketch demonstrates this problem.
    You have inadvertently discovered a bug in the Motor library, which I will fix soon.

    int x;
    void setup() {
      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
      x = 0;
    }
    
    // the loop routine runs over and over again forever:
    void loop() {
    
      byte y = map(x, 0, 100, 0, 255);
      Serial.print(x);
      Serial.print(" maps to ");
      Serial.println(y);
      x += 10;
      if(x>500) {
        x=0;
      }
      delay(1000);
    }
    
  2. Andrew

    i check all cables and jumpers but my car dont wantto change speed and dont run with this sketch and Orientation event

    test bluetooth work fine, arduino send name and pin and for any received information re-send random numbers. On speed 100 all work fine, butif i set 50-70-90 work only left motors, if i set 120-150 dont work anything 🙁 im sed….

Comments are closed.