Free Shipping Over $119



Self-balancing Car Kit For Arduino Robot Project 6: Bluetooth Test

Posted by Fiona Su on

Description:
The kit contains a Bluetooth XBee module, which is compatible with Android system.
Keyestudio Bluetooth XBee wireless module HC-06 has features of compact size, compatible with XBEE shield, and suitable for various 3.3V MCU systems. It also comes with efficient on-board antenna.

thumb

More contents check the link here.
https://wiki.keyestudio.com/Ks0144_keyestudio_XBee_Bluetooth_Wireless_Module_HC-06
In this project, go to learn how to use Bluetooth APP to make the balance car communicate with Android Bluetooth. You are able to use Bluetooth APP to randomly control the balance car move.

Note:
The keyestudio balance shield comes with a slide switch for controlling the Bluetooth communication.
When upload the source code, must turn the switch OFF; or else code uploading fails.
When connect to the Bluetooth module, should turn the switch ON.

KS0193-图片50.png

Ks0377.png

How to use Bluetooth APP?
Installed the balance car, upload the source code and power on; turn the power switch ON; turn the Bluetooth switch ON.
Install the Bluetooth APP, then you can see the right icon on your phone.

Click the link below to download the APP:

https://drive.google.com/open?id=1L69xdfmOvfhg0Wjh_p2FrtRkhs1h0fEu

Tap to open the Bluetooth APP; you will see the interface shown below.

KS0193-图片52.png

KS0193-图片53.png

Tap the Bluetooth icon KS0193-图片54.png; enter the Bluetooth search and pairing interface shown below.

KS0193-图片55.png

  • Tap the HC-06 (search at the first time is a address, so tap the address); the PIN is 1234.

KS0193-图片56.png

  • Finally you will see the paired device.

KS0193-图片57-.jpg

Connected HC-06 on your phone; now go to tap the Bluetooth connection icon on APP.KS0193-图片58.png

KS0193-图片59.png

  • Then tap the KS0193-图片60.png showed on the APP. Up to now, the Bluetooth should connect successfully.
  • Bluetooth connected, tap the key KS0193-图片61.png, the two motors of balance car turn forward;

tap the key KS0193-图片62.png , the two motors of balance car stop; tap the keyKS0193-图片63.png, the two motors of balance car turn backward.

Source Code:

//TB6612 pins
const int right_R1=8;    
const int right_R2=12;
const int PWM_R=10;
const int left_L1=7;
const int left_L2=6;
const int PWM_L=9;
char val;   // Bluetooth variable

void setup() 
{
  Serial.begin(9600);
  
  pinMode(right_R1,OUTPUT);   //set TB6612 pins OUTPUT
  pinMode(right_R2,OUTPUT);
  pinMode(PWM_R,OUTPUT);
  pinMode(left_L1,OUTPUT);
  pinMode(left_L2,OUTPUT);
  pinMode(PWM_L,OUTPUT);
}

void loop() 
{
  if(Serial.available())    //if serial buffer value is available
  {
    val = Serial.read();      //assign the value read from serial port to val
    Serial.println(val);
    switch(val)             //switch statement
    {
      case 'F': front(); break;     //motor turns front
      case 'B': back(); break;       //turn back
      case 'S': Stop();break;    //stop
    }
  }
}

//turn front
void front()
{
  digitalWrite(right_R1,HIGH);
  digitalWrite(right_R2,LOW);
  digitalWrite(left_L1,HIGH);
  digitalWrite(left_L2,LOW);
  analogWrite(PWM_R,100);
  analogWrite(PWM_L,100);
}
//turn back
void back()
{
  digitalWrite(right_R1,LOW);
  digitalWrite(right_R2,HIGH);
  digitalWrite(left_L1,LOW);
  digitalWrite(left_L2,HIGH);
  analogWrite(PWM_R,100);
  analogWrite(PWM_L,100);
}
//stop
void Stop()
{
  digitalWrite(right_R1,LOW);
  digitalWrite(right_R2,HIGH);
  digitalWrite(left_L1,LOW);
  digitalWrite(left_L2,HIGH);
  analogWrite(PWM_R,0);
  analogWrite(PWM_L,0);
}

Buy Self-balancing Car Kit For Arduino Robot

0 comments

Leave a comment

Please note, comments must be approved before they are published