Skip to content

Commit c75747c

Browse files
committed
SUMMER 2018
0 parents  commit c75747c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+21845
-0
lines changed

BLUETOOTH/MANDO/MANDO.ino

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#define POT_V A
2+
#defne POT_G A
3+
#define TIEMPO_MIN 100
4+
#define TIEMPO_MA 500
5+
unsigned long tiempo = 0;
6+
7+
int velocidad = 0;
8+
byte velocidad_i = 0
9+
byte velocidad_d= 0;
10+
11+
float giro = 0;
12+
13+
void setup()
14+
{
15+
Serial.begin(3840
16+
17+
tiempo = millis(
18+
void loop)
19+
{
20+
f (((millis() - tiempo) > TIEMPO_MIN) or ((millis() - tiempo) < TIEMPO_MAX))
21+
//
22+
velocidad = analogRead(POT_V)
23+
giro = analogRead(POT);
24+
25+
giro = map(giro, 0, 1023, 0, 100);
26+
velocidad_i = velocidad_d = map(velocidad, 0, 1023, 0, 100);
27+
giro = 50;
28+
29+
velocidad_d = velocidad_d * (1 - (giro/100));
30+
velocidad_i = velocidad_i * (gi
31+
Serial.print ("V: ");
32+
Serial.println((int)velocidad);
33+
Serial.print ("I: ");
34+
Serial.println((int)velocidad_i);
35+
Serial.print ("D: ");
36+
Serial.println((int)velocidad_d)
37+
*/
38+
Serial.write(velocidad_i + 100);
39+
Serial.write(velocidad_d + 100);
40+
41+
delay(200);
42+
//tiempo = millis();
43+
//
44+
}

BLUETOOTH/ROBOT/ROBOT.ino

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <Compluino_03.h>
2+
#define TIEMPO_MIN 100
3+
#define TIEMPO_MAX 300
4+
Compluino_03 Robot;
5+
6+
char velocidad_i = 0;
7+
char velocidad_d = 0;
8+
bool hay_datos = 0;
9+
unsigned long tiempo = 0;
10+
11+
void setup() {
12+
Robot.inicia();
13+
Robot.enciende(RGB_AMARILLO); // El robot se encuentra parado
14+
Robot.escribe_oled (3, 4, ">ColdPlay<");
15+
tiempo = millis();
16+
17+
Serial.begin(38400);
18+
19+
}
20+
21+
void loop() {
22+
if (Serial.available()> 1)
23+
{
24+
velocidad_i = Serial.read() - 100;
25+
velocidad_d = Serial.read() - 100;
26+
hay_datos = 1;
27+
}
28+
29+
if ((hay_datos and (TIEMPO_MIN < (millis() - tiempo))) or (TIEMPO_MAX > (millis() - tiempo)))
30+
{
31+
Robot.mueve_motor(PIN_MOTOR_D, velocidad_d);
32+
Robot.mueve_motor(PIN_MOTOR_I, velocidad_i);
33+
tiempo = millis();
34+
hay_datos = 0;
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#define POT_V A0
2+
#define POT_G A1
3+
#define T_LECTURA_A 200
4+
#define T_ESCRITURA 500
5+
#define PRECISION_A 8
6+
7+
unsigned long t_lectura_a = 0;
8+
unsigned long t_escritura = 0;
9+
char contador = 0;
10+
11+
int vel_p = 0;
12+
char velocidad = 0;
13+
char vel_anterior = 1;
14+
15+
int giro_p = 0;
16+
char giro = 0;
17+
char giro_anterior = 1;
18+
19+
void setup()
20+
{
21+
Serial.begin(38400);
22+
23+
t_lectura_a = millis();
24+
t_escritura = millis();
25+
}
26+
27+
void loop()
28+
{
29+
30+
//READ ANALOGICO
31+
if ((millis() - t_lectura_a) > T_LECTURA_A)
32+
{
33+
vel_p += analogRead(POT_V);
34+
giro_p += analogRead(POT_G);
35+
36+
if (vel_p < 50)
37+
vel_p = 0;
38+
if (giro_p < 50)
39+
giro_p = 0;
40+
41+
contador ++;
42+
Serial.println(vel_p);
43+
Serial.println(giro_p);
44+
if (contador == PRECISION_A)
45+
{
46+
contador = 0;
47+
vel_p = vel_p >> 3;
48+
giro_p = giro_p >> 3;
49+
giro = map(giro_p, 0, 1023, 0, 200);
50+
velocidad = map(vel_p, 0, 1023, 0, 200);
51+
Serial.println("final");
52+
Serial.println(vel_p);
53+
Serial.println(giro_p);
54+
vel_p = 0;
55+
giro_p = 0;
56+
}
57+
t_lectura_a = millis();
58+
}
59+
60+
//SEND
61+
if ((millis() - t_escritura) > T_ESCRITURA)
62+
{
63+
//VELOCIDAD
64+
if (vel_anterior != velocidad)
65+
{
66+
Serial.write('V');
67+
Serial.write(velocidad);
68+
vel_anterior = velocidad;
69+
}
70+
//GIRO
71+
if (giro_anterior != giro)
72+
{
73+
Serial.write('G');
74+
Serial.write(giro);
75+
giro_anterior = giro;
76+
}
77+
t_escritura = millis();
78+
}
79+
}

CAMAREROS_Y_LADRONES/FIRST_FIGHT.mp4

7.39 MB
Binary file not shown.

CAMAREROS_Y_LADRONES/SECOND_FIGHT.mp4

11.7 MB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#include <Compluino_03.h>
2+
#define AVANCE_RAPIDO 100
3+
#define CALIBRACION 40
4+
#define MUESTREO 10
5+
#define TIEMPO_GIRO 400
6+
#define TIEMPO_AVANCE 2000
7+
8+
int distancia = 0;
9+
int control_texto = 0;
10+
11+
Compluino_03 Robot;
12+
13+
void setup()
14+
{
15+
Robot.inicia();
16+
17+
Robot.escribe_oled(2, 0, "Siguelineas");
18+
Robot.escribe_oled(1, 1, "CON_OBSTACULOS");
19+
Robot.escribe_oled(0, 5, "Pulsa para");
20+
Robot.escribe_oled(0, 6, "Comenzar");
21+
Robot.escribe_oled(13, 7, "-->");
22+
Robot.espera_pulsador();
23+
Robot.borra_oled();
24+
}
25+
26+
void loop()
27+
{
28+
distancia = Robot.lee_distancia(0);
29+
if (control_texto > MUESTREO)
30+
Robot.escribe_oled_distancia(5,4,T_GRANDE,1);
31+
32+
if (distancia < 5)
33+
{
34+
// Robot.para();
35+
Robot.gira_izquierda(AVANCE_RAPIDO);
36+
Robot.espera_milisegundos(TIEMPO_GIRO);
37+
Robot.avanza(AVANCE_RAPIDO);
38+
Robot.espera_milisegundos(TIEMPO_AVANCE);
39+
40+
Robot.gira_derecha(AVANCE_RAPIDO);
41+
Robot.espera_milisegundos(4500);
42+
43+
while (Robot.lee_suelo_dd())
44+
Robot.avanza(AVANCE_RAPIDO);
45+
46+
47+
48+
}
49+
else
50+
{
51+
if (Robot.lee_suelo_dd() == BLANCO)
52+
{
53+
Robot.mueve_motor(PIN_MOTOR_D, AVANCE_RAPIDO);
54+
if (control_texto > MUESTREO)
55+
Robot.escribe_oled (15, 7, "B");
56+
}
57+
else
58+
{
59+
Robot.mueve_motor(PIN_MOTOR_D,CALIBRACION);
60+
if (control_texto > MUESTREO)
61+
Robot.escribe_oled (15, 7, "N");
62+
}
63+
64+
if (Robot.lee_suelo_id() == BLANCO)
65+
{
66+
Robot.mueve_motor(PIN_MOTOR_I, AVANCE_RAPIDO);
67+
if (control_texto > MUESTREO)
68+
Robot.escribe_oled (1, 7, "B");
69+
}
70+
else
71+
{
72+
Robot.mueve_motor(PIN_MOTOR_I,CALIBRACION);
73+
if (control_texto > MUESTREO)
74+
Robot.escribe_oled (1, 7, "N");
75+
}
76+
}
77+
if (control_texto > MUESTREO)
78+
control_texto = 0;
79+
control_texto ++;
80+
}

0 commit comments

Comments
 (0)