Vous êtes sur la page 1sur 11

UNIVERSIDAD TECNOLGICA DE CAMPECHE

ING. EN MECATRONICA

ASIGNATURA:
DISEO DE INTERFACES ELECTRNICAS

INTEGRANTES
JUAN MANUEL FRIAS SOSA
KELVIN LEEDER BRAILOVSKY
TSU EDGAR PEREZ CANTE

PROFESOR:
FELIPE DE JESS CABRERA ARMAS

GRADO Y GRUPO:
9A

PRACTICA:
SUMOBOTS

Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

UNIVERSIDAD TECNOLGICA DE CAMPECHE

ING. EN MECATRONICA

INTRODUCCIN
se realiz una prctica de un sumobot

MATERIALES
Los materiales que se utilizaron en esta prctica a continuacin se muestran en la
siguiente lista.

Software Arduino.
Arduino.
Software Processing
1 Bluetooth
1 protoboards.

Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

UNIVERSIDAD TECNOLGICA DE CAMPECHE

ING. EN MECATRONICA

Desarrollo.
Antes que nada, lo primero que hicimos es programar nuestro arduino para la
seal del control remoto hacia el sumobot y que el sumobot nos reciba el interfaz,
ya sea adelante, atrs, derecha o izquierda y por ltimo los sonidos del claxon y el
de la reversa.
Aqu mostraremos los cdigos del arduino de la seal del control remoto.
int
int
int
int
int

valor = 0;
motor1a= 3;
motor1b= 5;
motor2a = 6;
motor2b = 9;

void setup() {
Serial.begin(9600);
pinMode(motor1a, OUTPUT);
pinMode(motor1b, OUTPUT);
pinMode(motor2a, OUTPUT);
pinMode(motor2b, OUTPUT);
}
void loop() {
sumo();
}
void sumo(){
valor= Serial.read();
if(Serial.available() > 0){
}
if (valor== '0') {
detener();
Serial.println("0");
}
if (valor == '1') {
Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

UNIVERSIDAD TECNOLGICA DE CAMPECHE


ING. EN MECATRONICA

elant
Serial.println("1");
}
if (valor== '2') {
atras();
Serial.println("2");
}
if (valor == '3') {
derecha();
Serial.println("3");
}
if (valor == '4') {
izquierda();
Serial.println("4");
}
if (valor == '5') {
detener();
Serial.println("5");
}
}
void adelante()
{
analogWrite(motor1a, 200);
analogWrite(motor1b, 0);
analogWrite(motor2a, 200);
analogWrite(motor2b, 0);
}
void atras()
{
analogWrite(motor1a, 0);
analogWrite(motor1b, 200);
analogWrite(motor2a, 0);
analogWrite(motor2b, 200);
}
void derecha()
{
analogWrite(motor1a, 200);
analogWrite(motor1b, 0);
analogWrite(motor2a, 0);
analogWrite(motor2b, 200);
}
void izquierda()
{
Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

ad
e();

UNIVERSIDAD TECNOLGICA DE CAMPECHE


ING. EN MECATRONICA

alog
te(motor1a, 0);
analogWrite(motor1b, 200);
analogWrite(motor2a, 200);
analogWrite(motor2b, 0);
}

an
Wri

void detener()
{
analogWrite(motor1a, 0);
analogWrite(motor1b, 0);
analogWrite(motor2a, 0);
analogWrite(motor2b, 0);
}

Una vez hecho nuestros cdigos del arduino, ahora realizaremos nuestros cdigos
con processing.
Con processing lo que vamos a hacer es nuestra presentacin, y que dentro del
programa aparezca las flechas del sealamiento, tanto la derecha como izquierda
y adelante y atrs y tambin anexaremos los sonidos del claxon y reversa.
import processing.serial.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
Serial myPort;
PImage f;
PImage I;
PImage D;
PImage A;
PImage At;
PImage b;
int data;
FFT fft;
Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

UNIVERSIDAD TECNOLGICA DE CAMPECHE

ING. EN MECATRONICA

Minim
minim;
AudioPlayer Reversa;
AudioPlayer Claxon;
void setup()
{
size(600,600);
f=loadImage("Retrovisor.png");
I=loadImage("Izquierda.jpg");
D=loadImage("Derecha.jpg");
A=loadImage("Adelante.jpg");
At=loadImage("Atras.jpg");
b=loadImage("bocina.png");
minim = new Minim(this);
Reversa = minim.loadFile("Reversa.mp3");
Claxon = minim.loadFile("Claxon.mp3");
//Reversa.loop();
fft = new FFT(Reversa.bufferSize(), Reversa.sampleRate() );
myPort=new Serial (this, "COM16",9600);

}
void draw()
{
image(f,0,0,600,600);
fill(255,0,0);
Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

UNIVERSIDAD TECNOLGICA DE CAMPECHE

ING. EN MECATRONICA

text
("rece
d:"+data,10,50);
stroke(255);
fill(255);
if (data==1)
{
text("adelante", 200, 250);
fill(255, 0, 0);
image(A,300,50,100,100);
Claxon.pause();
Reversa.pause();
}
if (data==2)
{
text("atras", 200, 250);
fill(255, 0, 0);
image(At,300,110,100,100);
Reversa.play();
Claxon.pause();
}
if (data==3)
{
text("derecha", 200, 250);
fill(255, 0, 0);
image(D,508,45,100,100);
Reversa.pause();
Claxon.pause();
}
Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

ive

UNIVERSIDAD TECNOLGICA DE CAMPECHE

ING. EN MECATRONICA

if
(data==4)
{
text("izquierda", 200, 250);
fill(255, 0, 0);
image(I,100,45,100,100);
Reversa.pause();
Claxon.pause();
}
if (data==5)
{
text("claxon", 200, 250);
fill(255, 0, 0);
Claxon.play();
Reversa.pause();
image(b,285,30,100,100);
}
if (data==0)
{
text("detener", 200, 250);
fill(255, 0, 0);
Reversa.pause();
Claxon.pause();
}
}
void serialEvent (Serial myPort)
{
String input=myPort.readStringUntil(10);
if (input !=null)
Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

UNIVERSIDAD TECNOLGICA DE CAMPECHE

ING. EN MECATRONICA

{
inp
ut=trim (input);
data = int (input);
}
}

Ing. En Mecatrnica9A
JULIO MANUEL TORRES
ESPINOZA

Asi es como queda nuestro cdigo, y el programa aparece asi

Ya que tenemos listo nuestra 2 programas tanto arduino como processing, ahora
lo que vamos a hacer es nuestra comunicacin, hacia el sumobot por medio del
celular.

CONCLUSION

Aprendimos como mandar nuestra seal de arduino al processing, para que


nuestro sumobot caminara, y tambin vimos cmo nos reciba nuestra seal con
control remoto.

Vous aimerez peut-être aussi