loading

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!

Amazon kit I purchased: https://www.amazon.com/gp/product/B015CPT850/ref=oh_aui_detailpage_o06_s00?ie=UTF8&psc=1

Makerstudio webpage with product: http://makerstudio.cc/index.php?main_page=product_info&cPath=2&products_id=11

GoogleDrive with instructions and test code: https://drive.google.com/open?id=0B_d2pPrExdfYTDQ2SFdybHhJakE

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.

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.

*/ #include "EB_UltrasonicSensor.h" #include "EB_MotorDriver.h"

//Connect the Ultrasonic Sensor Trig to A2(D16, Echo to A3(D17) EB_UltrasonicSensor myUltrasonicSensor(16,17);

//M1_EN,M1_IN2,M1_IN1, M2_EN,M2_IN2,M2_IN1 EB_MotorDriver myMotorDriver(5,12,13, 6,7,8);

int speedl = 100; int speedr = 130;

void setup()

{ myMotorDriver.begin(); myUltrasonicSensor.begin(); Serial.begin(9600); }

void loop() { int distance = myUltrasonicSensor.distance(); // Serial.print("Distance cm:"); // Serial.println(distance); // delay(1000);

delay(50); //wait 50ms between pings of distance sensor

if(distance < 30) { rotate_right(); } else { drive_forward(); } }

void rotate_right() { myMotorDriver.run(speedl,speedr); delay(350); myMotorDriver.run(-speedl,speedr); delay(250); }

void drive_forward() { myMotorDriver.run(-speedl,-speedr); }

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.

His instructions on simple Bluetooth control: https://www.instructables.com/member/caiomoraes/

.ino file attached and text of Sketch follows:

#include "SoftwareSerial.h"
#include "EB_Bluetooth.h"

//EB_Bluetooth(RX, TX, INT) EB_Bluetooth myBluetooth(11,10,9);

void setup() {

Serial.begin(9600); //Set the baud rate to your Bluetooth module. myBluetooth.begin(); if(myBluetooth.setName("MakerStudio")){ Serial.println("Set Bluetooth Name Ok"); }else{ Serial.println("Set Bluetooth Name Failed"); } Serial.println("Waiting to be connected");

}

void loop() { char dat; if(myBluetooth.connected()){ if(myBluetooth.available()){ dat = myBluetooth.read(); Serial.print(dat); } if(Serial.available()){ dat = Serial.read(); myBluetooth.print(dat); } } }

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.

.ino attached and text below:

/*
Code to run robot car with Android app from Instructables beginner instructions. Makerstudio car, modules, and libraries Android app sends simple text commands, translate to movements

*/ #include "EB_MotorDriver.h" #include "EB_Bluetooth.h"

//M1_EN,M1_IN2,M1_IN1, M2_EN,M2_IN2,M2_IN1 EB_MotorDriver myMotorDriver(5,12,13, 6,7,8);

//EB_Bluetooth(RX, TX, INT) EB_Bluetooth myBluetooth(11,10,9);

void setup() { Serial.begin(9600); //Set the baud rate myBluetooth.begin(); myMotorDriver.begin(); }

void loop() { char command; if(myBluetooth.connected()){ if(myBluetooth.available()){ command = myBluetooth.read();

myMotorDriver.run(0,0); //initialize with motors stopped

switch(command){ case 'F': myMotorDriver.run(-180,-180); //change numbers to increase or decrease left,right motor speed break; case 'B': myMotorDriver.run(150,150); break; case 'L': myMotorDriver.run(-80,-120); break; case 'R': myMotorDriver.run(-120,-80); break; case 'G': //Forward Left myMotorDriver.run(-80,-180); break; case 'I': //Forward Right myMotorDriver.run(-180,-80); break; } } } }

Step 5: Operate Car With Line Following Module

I haven't had a chance to write this Sketch yet, so please comment if you have!! Thanks for reading!

<p>Awesome! Did you take any progress photos from when you were putting it together?</p>
<p>Not really. The .pdf instructions are 38 pages of true love! They show every piece as it is installed, very thorough.</p>

About This Instructable

510views

9favorites

License:

More by yieldmap:Makerstudio 2-wheel Robot Arduino Bluetooth Android Smart Car 
Add instructable to: