Victor Diaz @victornomad

CRAZY ROBOTICS UPM-bq Hacklab, Madrid
Victor Diaz @victornomad
Que necesitamos?
Materiales
dispositivo Android > 4.0
Microcontrolador
(Arduino w Bluetooth - Zum)
Protocoder.org
Ordenador ?
Un poco de locura
2xMicroServos
2xServos (rotación continua)
Carton
Papel
Rotuladores
Tijeras
Bridas
Cinta adhesiva doble cara
Cinta adhesiva
Sorpresa
Sorpresa
CRAZY ROBOTICS
String inputString = "";
boolean stringComplete = false;
// a string to hold incoming data
// whether the string is complete
void getCommands() {
if (Serial.available()) {
while (Serial.available()) {
char inChar = (char)Serial.read();
inputString += inChar;
if (inChar == '\n') {
stringComplete = true;
Serial.println(inputString);
break;
}
}
}
#include <Servo.h>
Servo servoQ, servoW, servoE, servoR;
int led = 13;
//commands
if (stringComplete) {
if(inputString.startsWith("q")){
int val = inputString.substring(1).toInt();
servoQ.write(val);
} else if(inputString.startsWith("w")){
int val = inputString.substring(1).toInt();
servoW.write(val);
} else if(inputString.startsWith("e")){
int val = inputString.substring(1).toInt();
servoE.write(val);
} else if(inputString.startsWith("r")){
int val = inputString.substring(1).toInt();
servoR.write(val);
} else if(inputString.startsWith("l")){
int val = inputString.substring(1).toInt();
if (val == 0) {
digitalWrite(led, LOW);
} else {
digitalWrite(led, HIGH);
}
}
void setup() {
pinMode(led, OUTPUT);
//servos
servoQ.attach(12);
servoW.attach(11);
servoE.attach(10);
servoR.attach(9);
//reset
servoQ.write(90);
servoW.write(90);
servoE.write(90);
servoR.write(90);
//Setup usb serial connection to computer
Serial.begin(19200);
delay(500);
}
void loop() {
getCommands();
delay(25);
}
inputString = "";
stringComplete = false;
}
}
CRAZY ROBOTICS
//--------------------- Robot class
function Robot() {
this.start = function() {
network.connectBluetoothSerialByUi(function(m, data) {
console.log(data);
});
}
Esto aun sigue
this.scan = function() {
network.scanBluetoothNetworks(function(n, m, s) {
console.log("hola", n, m, s);
});
}
this.fullServo1 = function(speed) {
network.sendBluetoothSerial("q"+speed + "\n");
}
siendo un telefono
var robot = new Robot();
robot.start();
robot.say("hello everybody");
robot.fullServo1(90);
robot.led(0)
this.fullServo2 = function(speed) {
network.sendBluetoothSerial("w"+speed + "\n");
}
var slider1 = ui.addSlider(20, 20, ui.sw - 20, -1, 180, 1,
function(progress){
var iP = Math.round(progress);
robot.fullServo1(iP);
});
this.microServo1 = function(angle) {
network.sendBluetoothSerial("e"+angle + "\n");
}
this.microServo2 = function(angle) {
network.sendBluetoothSerial("r"+angle + "\n");
}
var slider2 = ui.addSlider(20, 120, ui.sw - 20, -1, 180, 1,
function(progress){
var iP = Math.round(progress);
robot.fullServo2(iP);
});
this.led = function(state) {
network.sendBluetoothSerial("l"+state + "\n");
}
this.playSound = function(name) {
media.playSound(name);
}
var slider3 = ui.addSlider(20, 220, ui.sw - 20, -1, 180, 1,
function(progress){
var iP = Math.round(progress);
robot.microServo1(iP);
});
this.say = function(text) {
media.textToSpeech(text);
}
var slider4 = ui.addSlider(20, 320, ui.sw - 20, -1, 180, 1,
function(progress){
var iP = Math.round(progress);
robot.microServo2(iP);
});
this.showImage = function(name) {
ui.setBackgroundImage(name);
}
ui.setBackgroundImage("robot.png");
}
this.stop = function() {
}
CRAZY ROBOTICS
Zum + Firmware
Pin 12
Pin 11
Pin 10
Pin 9
Protocoder
q[0-180]
w[0-180]
e[0-180]
r[0-180]
DEMO + Truquetes
CRAZY ROBOTICS
Pero…
CRAZY ROBOTICS
Nombre Equipo
Nombre 1
Nombre 2
Nombre 3
…
Nombre N
superpoder
nombre
origen
heroe / villano
finalidad
CRAZY ROBOTICS