0% found this document useful (0 votes)
20 views2 pages

Robot Soccer 2025

The document describes a robot soccer control system using an Arduino and Bluetooth module. It includes code for motor control functions such as moving forward, backward, turning, and stopping based on received Bluetooth commands. The setup involves defining motor control pins and establishing Bluetooth communication for remote operation.

Uploaded by

ercom.edu
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)
20 views2 pages

Robot Soccer 2025

The document describes a robot soccer control system using an Arduino and Bluetooth module. It includes code for motor control functions such as moving forward, backward, turning, and stopping based on received Bluetooth commands. The setup involves defining motor control pins and establishing Bluetooth communication for remote operation.

Uploaded by

ercom.edu
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/ 2

ROBOT SOCCER

OUT 1 OUT 4

OUT 2 +12V GND +5V


ENA ENB OUT 3

IN1

IN2

IN3

IN4

CAFINI
1200MAH
4.2V

CAFINI
4.2V
1200MAH

APP ( Arduino Bluetooth Controller)


#include <SoftwareSerial.h>

// Definimos el puerto Bluetooth en A0 (RX) y A1 (TX)


SoftwareSerial BT(A0, A1); // RX, TX

#define FORWARD 'F'


#define BACKWARD 'B'
#define LEFT 'L'
#define RIGHT 'R'
#define CIRCLE 'C'
#define CROSS 'X'
#define TRIANGLE 'T'
#define SQUARE 'S'
#define START 'A'
#define PAUSE 'P'

// Pines para los motores


const int IN1 = 4;
const int IN2 = 5;
const int IN3 = 6;
const int IN4 = 7;

void setup() {
BT.begin(9600); // Comunicación con módulo Bluetooth
Serial.begin(9600); // Comunicación con el monitor serial (opcional)

// Configurar pines de salida para los motores


pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);

// Detener motores al inicio


stopMotors();
}

void loop() {
if (BT.available()) {
char command = BT.read();
Serial.println(command); // Muestra el comando en el monitor serial (opcional)
executeCommand(command);
}
}

// Funciones de control de motores


void moveForward() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}

void moveBackward() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}

void turnLeft() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}

void turnRight() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}

void stopMotors() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}

void executeCommand(char command) {


switch (command) {
case FORWARD:
moveForward();
break;
case BACKWARD:
moveBackward();
break;
case LEFT:
turnLeft();
break;
case RIGHT:
turnRight();
break;
case CROSS:
case PAUSE:
stopMotors();
break;
default:
// Comando desconocido
break;
}
}

You might also like