Control RC Car with Acceleration Sensor on Smartphone

Make things

Controlling RC car by acceleration sensor on Smartphone.

Obniz make it easy to use smartphone sensors for electronics.

Materials

  • obniz x1
  • power supply for obniz x1
  • Smartphone with acceleration sensor x1
  • DC Motor x1
  • RC car tire x2
  • cardboard and paper, etc

How to make

Hardware connection

We are expecting to control RC car by two tires made of DC Motor in this blog.

Wire DC Motors like the table and the image below. Please adjust the direction of the DC Motors properly, because rotation direction depends on the DC Motors’ direction.

obniz DC Motors
0 [left DC Motor] OUT1
1 [left DC Motor] OUT2
2 [right DC Motor] OUT1
3 [right DC Motor] OUT2

Put DC Motors to tires and make the body of RC car with cardboard and paper, etc.

Software

You can get acceleration sensor value using only 3 lines.

window.addEventListener("devicemotion", function (event1) {
    let x = event1.accelerationIncludingGravity.x;
 }

Program