9

Click here to load reader

Reporte

Embed Size (px)

Citation preview

Page 1: Reporte

UNIVERSIDAD TECNOLÓGICA DE CAMPECHEING. EN MECATRONICA

Ing. En Mecatrónica“9A”JULIO MANUEL TORRES ESPINOZA

|

ASIGNATURA:DISEÑO DE INTERFACES ELECTRÓNICAS

INTEGRANTESJUAN MANUEL FRIAS SOSA

KELVIN LEEDER BRAILOVSKYTSU EDGAR PEREZ CANTE

PROFESOR:FELIPE DE JESÚS CABRERA ARMAS

GRADO Y GRUPO:

9 A

PRACTICA:SUMOBOTS

Page 2: Reporte

UNIVERSIDAD TECNOLÓGICA DE CAMPECHEING. EN MECATRONICA

Ing. En Mecatrónica“9A”JULIO MANUEL TORRES ESPINOZA

|

INTRODUCCIÓN

se realizó una práctica de un sumobot

MATERIALES Los materiales que se utilizaron en esta práctica a continuación se muestran en la

siguiente lista.

Software Arduino.

Arduino.

Software Processing

1 Bluetooth

1 protoboards.

Page 3: Reporte

UNIVERSIDAD TECNOLÓGICA DE CAMPECHEING. EN MECATRONICA

Ing. En Mecatrónica“9A”JULIO MANUEL TORRES ESPINOZA

|

Desarrollo.

Antes que nada, lo primero que hicimos es programar nuestro arduino para la

señal del control remoto hacia el sumobot y que el sumobot nos reciba el interfaz,

ya sea adelante, atrás, derecha o izquierda y por último los sonidos del claxon y el

de la reversa.

Aquí mostraremos los códigos del arduino de la señal del control remoto.

int valor = 0; int motor1a= 3;int motor1b= 5;int motor2a = 6;int 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') {

adelante(); 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()

Page 4: Reporte

UNIVERSIDAD TECNOLÓGICA DE CAMPECHEING. EN MECATRONICA

Ing. En Mecatrónica“9A”JULIO MANUEL TORRES ESPINOZA

|

{

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() {

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

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

Una vez hecho nuestros códigos del arduino, ahora realizaremos nuestros códigos

con processing.

Con processing lo que vamos a hacer es nuestra presentación, y que dentro del

programa aparezca las flechas del señalamiento, tanto la derecha como izquierda

y adelante y atrás y también 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;

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");

Page 5: Reporte

UNIVERSIDAD TECNOLÓGICA DE CAMPECHEING. EN MECATRONICA

Ing. En Mecatrónica“9A”JULIO MANUEL TORRES ESPINOZA

|

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);

text("received:"+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();

}

if (data==4)

{

text("izquierda", 200, 250);

fill(255, 0, 0);

image(I,100,45,100,100);

Reversa.pause();

Claxon.pause();

}

if (data==5)

Page 6: Reporte

UNIVERSIDAD TECNOLÓGICA DE CAMPECHEING. EN MECATRONICA

Ing. En Mecatrónica“9A”JULIO MANUEL TORRES ESPINOZA

|

{

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)

{

input=trim (input);

data = int (input);

}

}

Asi es como queda nuestro código, y el programa aparece asi

Page 7: Reporte

UNIVERSIDAD TECNOLÓGICA DE CAMPECHEING. EN MECATRONICA

Ing. En Mecatrónica“9A”JULIO MANUEL TORRES ESPINOZA

|

Ya que tenemos listo nuestra 2 programas tanto arduino como processing, ahora

lo que vamos a hacer es nuestra comunicación, hacia el sumobot por medio del

celular.

Page 8: Reporte

UNIVERSIDAD TECNOLÓGICA DE CAMPECHEING. EN MECATRONICA

Ing. En Mecatrónica“9A”JULIO MANUEL TORRES ESPINOZA

|

CONCLUSION

Aprendimos como mandar nuestra señal de arduino al processing, para que

nuestro sumobot caminara, y también vimos cómo nos recibía nuestra señal con

control remoto.