Secondary Menu

Makerstudio 2-wheel Robot Arduino Bluetooth Android Smart Car

My son and I decided to get started into Arduino building and programming by purchasing a couple of kits from Amazon. The kit I bought turned out to be manufactured by Makerstudio, who had a Google Drive for their instructions and code. The build instructions were very good, thorough, and the module testing code was good also. The problem came with the actual operation Sketch, which was not provided!! So, here's some instructions!

Step 1: Build the Robot Car

Follow the detailed instructions in the .pdf doc to build the car. Make sure to use the test code from the Google Drive to test each of the modules as you build. The code and libraries are specific to the electronic components in the kit, and they work well to test. The Arduino IDE Serial Monitor is used to view the data incoming from the sensors while you are testing, ie Ultrasonic sensor, Line Follow sensor, and Bluetooth module.

Attachments

Step 2: Obstacle Avoidance

Next step is to try some robot action by using the Ultrasonic sensor to help avoid obstacles. As you look through the Sketch, first step is to include the libraries for the Ultrasonic sensor and Motor Driver module. Connections are the same as the build instructions, so no changes there. You'll notice the two speed values, speedl and speedr. One of my motors was a bit slower, so the different values helped it track straight. In the loop, the arduino requests a distance value from the Ultrasonic sensor every 50ms, which reports back in cm. If the value is less than 30cm, the robot turns right, else it drives forward. Next we define what the two actions are, rotate right and straight. You'll also notice the rotate_right code has the robot reverse for 350ms before it turns right for 250ms. Feel free to change any of the speed numbers for your car.

Attached is the .ino file, and here's the text:

/*Makerstudio robot car and modules Code uses Ultrasonic sensor to determine distance, then reverse and turns if 30cm or less. Otherwise forward. Speedl and r are different to help car track straight.

Attachments

Step 3: Test Bluetooth

Shout out to caiomoraes here on Instructables for the bluetooth app, and simple instructions on how to use it. I downloaded the app to my Android and used the following code to test the bluetooth connection to the robot car. Use his app to connect the Android app to your car, it should be called MakerStudio when searching for devices. Upload the Sketch to the car, leave the USB connected and open Serial Monitor. You should see a line of SSSS from the app, signifying a Stop signal. If you press the app buttons for Forward, Back, Left or Right, you will see a line of each of those commands FFFFF, BBBBB, LLLLL, or RRRR. This will verify your Arduino is correctly receiving commands from the app through the Bluetooth module.

Attachments

Step 4: Operate Car With App

Finally you're ready to teach the car what to do when it receives the Forward, Back etc commands from the app. Walking through the Sketch, first you're including the libraries to drive the motors, use the Serial connection, and Bluetooth. Next, tell the Arduino board where the motor driver and bluetooth are connected. In Setup, set the serial baud rate, start the Bluetooth service and Motor driver. In the Loop, the Sketch basically reads from the bluetooth and sets the variable "command" for the car direction. No command means motor speeds of 0, or stopped. If the Bluetooth command is F, B, R, L, etc then the motor drivers have different speeds to correspond with those directions. Pretty simple.