0% found this document useful (0 votes)
174 views21 pages

Robosapien W - Bluetooth Remote Control - MakeHackVoid

This document describes a project to add Bluetooth control to a Robosapien robot using an Arduino. It involves connecting an HM-10 Bluetooth module to an Arduino, decoding signals from a Bluetooth remote, and using Arduino code to command the Robosapien's infrared signals for motion. Code examples are provided to decode signals, define commands, and send infrared commands from the Arduino to control the Robosapien remotely via Bluetooth.

Uploaded by

RICHARD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
174 views21 pages

Robosapien W - Bluetooth Remote Control - MakeHackVoid

This document describes a project to add Bluetooth control to a Robosapien robot using an Arduino. It involves connecting an HM-10 Bluetooth module to an Arduino, decoding signals from a Bluetooth remote, and using Arduino code to command the Robosapien's infrared signals for motion. Code examples are provided to decode signals, define commands, and send infrared commands from the Arduino to control the Robosapien remotely via Bluetooth.

Uploaded by

RICHARD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.

com/projects/robosapien-w-bluetooth-remote/

1 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

2 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

3 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

4 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

5 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

6 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

7 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

8 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

9 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

10 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

11 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

void loop()
{
unsigned char val = 0;
unsigned long start, ts, dur;

while(digitalRead(irPin)) {
start = micros();
}

while(!digitalRead(irPin)) { // preamble is 8ts spent low,


use to sync clocks
ts = (micros() - start) / 8;
}

for(char b = 7; b >= 0; b--) {


start = micros();
while(digitalRead(irPin)) {
dur = micros() - start;
}
if(dur > ts*2)
val |= 1<<b;
while(!digitalRead(irPin)) { }
}

Serial.println(val, HEX);
}

12 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

void loop()
{
writeCommand(leftArmUp);
delay(2000);
writeCommand(walkForward);
delay(3000);
writeCommand(rightArmUp);
delay(2000);
writeCommand(turnLeft);
delay(3000);
writeCommand(stopMoving);
delay(500);
writeCommand(burp);
delay(3000);
}

13 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

enum roboCommand {
// only a very small subset of commands
turnRight = 0x80,
rightArmUp = 0x81,
rightArmOut = 0x82,
tiltBodyRight = 0x83,
rightArmDown = 0x84,
rightArmIn = 0x85,
walkForward = 0x86,
walkBackward = 0x87,
turnLeft = 0x88,
leftArmUp = 0x89,
leftArmOut = 0x8A,
tiltBodyLeft = 0x8B,
leftArmDown = 0x8C,
leftArmIn = 0x8D,
stopMoving = 0x8E,

// noises
whistle = 0xCA,
roar = 0xCE,
burp = 0xC2
};

14 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

void delayTs(unsigned int slices) {


delayMicroseconds(tsDelay * slices);
}

void writeCommand(unsigned char cmd)


{
pinMode(irPin, OUTPUT);

// preamble
digitalWrite(irPin, LOW);
delayTs(8);

for(char b = 7; b>=0; b--) {


digitalWrite(irPin, HIGH);
delayTs( (cmd & 1<<b) ? 4 : 1 );
digitalWrite(irPin, LOW);
delayTs(1);
}

digitalWrite(irPin, HIGH);
pinMode(irPin, INPUT);
}

15 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

16 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

17 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

18 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

19 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

**Using Arduino Mega 2560**


*sanyaade — Thu, 28/06/2012 - 10:06am*
Hello, Great hack!

Can I use Arduino Mega 1260 or 2560?

God blesses!!!

Best regards,

Sanyaade

20 of 21 3/31/2018, 2:38 PM
Robosapien w/ Bluetooth remote control — MakeHackVoid https://makehackvoid.com/projects/robosapien-w-bluetooth-remote/

21 of 21 3/31/2018, 2:38 PM

You might also like