CAVEDU EducationDFRobot
Published © GPL3+

Control Mearm with Arduino 101 and Android Phone

This topic will introduce a popular education robot arm - mearm with Arduino 101. And build Android app with MIT App Inventor to control it.

IntermediateFull instructions provided5 hours2,134
Control Mearm with Arduino 101 and Android Phone

Things used in this project

Hardware components

DFRobot Arduino 101
×1
DFRobot 9g micro servo
×1
mearm
open source https://www.thingiverse.com/thing:360108, but you can buy this kit
×1
PCA9685 I2C 16-servo control board
×1

Software apps and online services

Arduino IDE
Arduino IDE
MIT App Inventor
MIT App Inventor

Story

Read more

Schematics

4 servo with PCA9685

Code

Arduino 101 control 4 servos using PCA9685 and receiving BLE data

Arduino
#include <CurieBLE.h>
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
 
#define SERVOMIN  150 
#define SERVOMAX  600 
 
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
 
BLEService BLE_serv("19B10010-E8F2-537E-4F6C-D104768A1214");
BLEUnsignedIntCharacteristic BLE_char("19B10011-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
 
void setup() 
{
    Serial.begin(9600);
    pwm.begin();
    pwm.setPWMFreq(60);
 
    BLE.begin();
    BLE.setLocalName("mearm");
    BLE.setAdvertisedService(BLE_serv);
    BLE_serv.addCharacteristic(BLE_char);
    BLE.addService(BLE_serv);
    BLE_char.setValue(0);
    BLE.advertise();
 
    Serial.println("Waiting for connections...");
}
 
void loop() {
    BLEDevice central = BLE.central();
    if(central)
    {
        Serial.print("Connected to central");
        Serial.println(central.address());
        while(central.connected())
            if(BLE_char.written())
            {
                int servo_num = BLE_char.value();
                int pulse_len = BLE_char.value();
                pwm.setPWM(servo_num, 0, pulse_len);
            }
        Serial.println("disconnected");
    }
}

Credits

CAVEDU Education

CAVEDU Education

11 projects • 28 followers
We provide tutorials of robotics, Arduino, Raspberry Pi and IoT topics. http://www.cavedu.com
DFRobot

DFRobot

66 projects • 146 followers
Empowering Creation for Future Innovators

Comments