5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10



4DOF Robot Arm Project 4: Bluetooth Controlled Robot Arm

Posted by Fiona Su on

1) Principle of Bluetooth Control

Bluetooth, as the name implies, blue teeth, and he is not used to bite people, but a wireless data transmission method. Bluetooth technology is a wireless standard technology that enables short-range data exchange among fixed devices, mobile devices, and personal area networks of buildings (UHF radio waves in the ISM band of 2.4 to 2.485 GHz).
There are two kinds of commonly used Bluetooth module on the market, HC-05 and HC-06 models.
The difference between them is that the HC-05 is a master-slave one. It can not only make small reports to its own “master”, but also can receive the command given to it. The HC-06 can only work in slave mode, which can only accept the superior command. For instance, in many cases you may want to be an overbearing man, letting subordinates obey the order without any nonsense. In such situation, it is enough to use the HC-06 module.
Note: HC-06 Bluetooth module is only compatible with Android system, not support iOS.

thumb

Specification Parameters:
1) Bluetooth Protocol: Bluetooth 2.1+ EDR Standard
2) USB Protocol: USB v1.1/2.0
3) Operating Frequency: 2.4GHz ISM Frequency Band
4) Modulation Mode: Gauss Frequency Shift Keying
5) Transmit Power: ≤ 4dBm, Second Stage
6) Sensitivity: ≤-84dBm at 0.1% Bit Error Rate
7) Transmission Speed: 2.1Mbps(Max)/160 kbps(Asynchronous);1Mbps/1Mbps(Synchronous)
8) Safety Feature: Authentication and Encryption
9) Supported Configuration: Bluetooth Serial Port (major and minor)
10) Supply Voltage: DC 5V
11) Operating Temperature: -20 to 55℃

2)Bluetooth Control Key Test

Description:
Next, we are going to introduce the use method for HC-06 Bluetooth module. To easily use the HC-06 Bluetooth module to control the robot arm, we particularly design the APP control. Shown below.

thumb

You can download the APP from the link:
https://drive.google.com/open?id=10U7EWyCyb5bGUxWm3DXRXGKEm1UQGU4Q
There are 10 control keys on the App. When connect well the HC-06 Bluetooth module to Android phone using our APP, press the control key, Android phone will receive a corresponding value.
When programming, you can set the function for the corresponding value. So in the experiment, we will test each key to get the corresponding value.
Pay special attention to:
1) First should pair Bluetooth in the phone settings. Connect the Bluetooth to shield, powered up, LED on the Bluetooth module flashes, then open the mobile Bluetooth, search for a Bluetooth device.
If find a new address, pair and enter 1234, paired successfully, you should see the address name change to HC-06.
2) Must first upload the test program successfully, then connect the Bluetooth, pair and connect the App. Otherwise, fail to upload the program.

thumb

Hookup Guide:

thumb

Test Code 8:

void setup() 
{
  Serial.begin(9600);     // set the serial baud rate to 9600
}

void loop()
{
  char val;    // define a variable, used to receive the value read from Bluetooth.
  if(Serial.available())     // if receive the value 
  {
    val = Serial.read();       // assign the value read to val
    Serial.println(val);
  }
}

Test Result:
Upload the code, hookup well and power up. After connecting the Bluetooth APP, open the serial monitor and set the baud rate to 9600, press down the control key on the APP, you should see the corresponding value. Shown below.

key value
one 1
two 2
three 3
four 4
five 5
A A
B B
C C
D D
E  E

3)Bluetooth Controlling Arm

Description:
In this experiment, we combine a Android APP and HC-06 Bluetooth module to control the robot arm.
The controlling method are shown below.

key Corresponding arm action
one The lower arm stretches out
two The clamp claw opens
three The clamp claw is closed
four The lower arm draws back
five -
A The upper arm lifts up
B The arm turns left
C The arm turns right
D The upper arm goes down
E -

Hookup Guide:

thumb

thumb

Test Code 9:

#include <Servo.h>  // add the servo libraries
Servo myservo1;  // create servo object to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;
int pos1=80, pos2=60, pos3=130, pos4=0;  // define the variable of 4 servo angle and assign the initial value( that is the boot posture angle value)
char val;

void setup()
{
   // boot posture
  myservo1.write(pos1);  
  delay(1000);
  myservo2.write(pos2);
  myservo3.write(pos3);
  myservo4.write(pos4);
  delay(1500);

  Serial.begin(9600); //  set the baud rate to 9600
}

void loop() 
{
  myservo1.attach(A1);  // set the control pin of servo 1 to A1
  myservo2.attach(A0);  // set the control pin of servo 2 to A0
  myservo3.attach(6);   // set the control pin of servo 3 to D6
  myservo4.attach(9);   // set the control pin of servo 4 to D9

  if(Serial.available())   // if receive the data
  {
    val=Serial.read();    // read the received data
    Serial.println(val);
   
    switch(val)   
    {
      case 'B':  T_left();  break;   // execute the corresponding function when receive the value 
      case 'C':  T_right();  break;
      case 'A':  RF();  break;
      case 'D':  RB();  break;
      case '2':  ZK();  break;
      case '3':  ZB();  break;
      case '1':  LF();  break;
      case '4':  LB();  break;
    }
  }
}
//**************************************************
// turn left
void T_left()
{
    pos1=pos1+1;
    myservo1.write(pos1);
    delay(5);
    if(pos1>180)
    {
      pos1=180;
    }
}
//turn right 
void T_right()
{
    pos1=pos1-1;
    myservo1.write(pos1);
    delay(5);
    if(pos1<1)
    {
      pos1=1;
    }
}
//********************************************
//open the claw
void ZK()
{
      pos4=pos4-2;
      Serial.println(pos4);
      myservo4.write(pos4);
      delay(5);
      if(pos4<2)
      {
        pos4=0;
      }
}
// close the claw
void ZB()
{
    pos4=pos4+8;
      Serial.println(pos4);
      myservo4.write(pos4);
      delay(5);
      if(pos4>108)
      {
        pos4=108;
      }
}

//******************************************
// the upper arm will lift up 
void RF()
{
    pos2=pos2-1;
    myservo2.write(pos2);
    delay(5);
    if(pos2<0)
    {
      pos2=0;
    }
}
// the upper arm will go down 
void RB()
{
    pos2=pos2+1;
    myservo2.write(pos2);
    delay(5);
    if(pos2>180)
    {
      pos2=180;
    }
}

//***************************************
// the lower arm will stretch out 
void LB()
{
  pos3=pos3+1;
    myservo3.write(pos3);
    delay(5);
    if(pos3>180)
    {
      pos3=180;
    }
}
// the lower arm will draw back 
void LF()
{
  pos3=pos3-1;
    myservo3.write(pos3);
    delay(5);
    if(pos3<35)
    {
      pos3=35;
    }
}

Test Result:
Upload the code, connect it up and power on, after connecting the Bluetooth APP, press the key to control the robot arm do commanded motions.

Tutorial

Buy >> 4DOF Acrylic Toys Robot Mechanical Arm Claw Kit for Arduino DIY Robot

 

0 comments

Leave a comment

Please note, comments must be approved before they are published