SpyBot: Bluetooth-controlled mBed Robot with Raspberry Pi IP Camera

  • Peter John
  • Rohit Ganesan
  • Jason McNeely
  • Lucas Kinser

Description

SpyBot is a bluetooth controlled robot that transmits live streaming video to a web terminal over WiFi. The robot uses an NXP1768 mbed and H-bridge combined with an Adafruit Blufruit Bluetooth module for robot control. in adition to the robot motion controls, camera position is performed using a servo controlled by the mbed board. All functions are performed using a bluetooth remote control installed on a smartphone. Image capture, processing, and streaming is performed with a Raspberry Pi Zero W and Raspberry Pi camera module then streamed live to a web terminal over WiFi.

Components

  • NXP LPC 1768 mbed board
  • H-bridge motor controller
  • Adafruit Blufruit Bluetooth module
  • Raspberry Pi Zero W
  • Raspberry Pi Camera module version 2
  • Hitec Hs 322Hd Servo Motor
  • Shadow Robot Kit

Pinouts

H-Bridge

MBEDH-BridgeMotor
P26PWMA
P21PWMB
P17AIN1
P18AIN2
P19BIN1
P20BIN2
VccVcc
VoutVMOT
VccSTBY
GndGnd
AO1Right Motor -
AO2Right Motor +
BO1Left Motor +
BO2Left Motor -

BluFruit

MBEDBluFruit
GndCTS
GndGnd
VccVin
P27TXO
P28RXI

Servo

MBEDServo
P22Signal/Yellow
VccPower/Red
GndGnd/Black

Paspberry Pi Zero W

Self contained with only power needing to be wired.

Mbed Robot Control Code

#include "mbed.h"
#include "motordriver.h"
#include "rtos.h"
#include "Servo.h"
 
RawSerial blue(p28,p27);//bluetooth chip
BusOut myled(LED1,LED2,LED3,LED4);
 
Motor A(p26, p18, p17, 1); // LEFT pwm, fwd, rev, can brake
Motor B(p21, p19, p20, 1); // RIGHT
 
Servo myservo(p22);
float p=0.5;
 
int main(){
    char bnum=0;
    char bhit=0;

    while(1){
        if (blue.getc()=='!'){
            if (blue.getc()=='B'){ //button data packet
                bnum = blue.getc(); //button number
                bhit = blue.getc(); //1=hit, 0=release
                {
                    myled = bnum - '0'; //current button number will appear on LEDs
                    switch (bnum){
                        case '6': //number button 6
                          
                                if (bhit=='1'){
                                    A.speed(1);
                                    B.speed(1);
                                }
                                else{
                                    A.speed(0);
                                    B.speed(0);
                                }
                        
                            break;
                         case '1': //number button 1
                            if (bhit=='1') {
                                 p += 0.1;
                                 myservo = p;
                                 wait(0.1);  
                            }
                            break;
                            case '2': //number button 2
                            if (bhit=='1'){
                                 p -= 0.1;
                                 myservo = p;
                                 wait(0.1);
                            }
                            break;
                        case '5': //number button 5
                            if (bhit=='1') {
                                A.speed(-1);
                                B.speed(-1);
                            } else {
                                A.speed(0);
                                B.speed(0);
                            }
                            break;
                        case '7': //button 7 left arrow
                            if (bhit=='1') {
                                A.speed(-0.75);
                                B.speed(0.75);
                            } else {
                                A.speed(0);
                                B.speed(0);
                            }
                            break;
                        case '8': //button 8 right arrow
                            if (bhit=='1') {
                                A.speed(0.75);
                                B.speed(-0.75);
                            } else {
                                A.speed(0);
                                B.speed(0);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
        }
    }//end of while(1)
}//end of main

Raspberry Pi Software Setup

The basic Spy Bot camera set up and installation can be performed if the following tutorial is followed.

http://www.toptechboy.com/tutorial/low-cost-raspberry-pi-ip-camera/

Video Demonstration

Notes


Please log in to post comments.