This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 0 voto(s) - 0 Media
  • 1
  • 2
  • 3
  • 4
  • 5
rc bluetooth
#1
Hola buenas escribo para pedir ayuda sobre un coche con bluetooth. Tiene 1 motor y me gustaria conectarlo al bluetooth, consigo que funcionen a la vez pero el bluetooth es como si no funcionara sobre el motor. Estaría muy agradecido si alguien me ayudara por favor. Es un motor normal y su circuito es un cable al 5v y otroal GND
Aquí esta el código: int motorPin1 = 3; // pin 2 on L293D IC
int motorPin2 = 4; // pin 7 on L293D IC
int enablePin = 5; // pin 1 on L293D IC
int state;
int flag=0; //makes sure that the serial only prints once the state

void setup() {
// sets the pins as outputs:
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(enablePin, OUTPUT);
// sets enablePin high so that motor can turn on:
digitalWrite(enablePin, HIGH);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

void loop() {
//if some date is sent, reads it and saves in state
if(Serial.available() > 0){
state = Serial.read();
flag=0;
}
// if the state is '0' the DC motor will turn off
if (state == '0') {
digitalWrite(motorPin1, LOW); // set pin 2 on L293D low
digitalWrite(motorPin2, LOW); // set pin 7 on L293D low
if(flag == 0){
Serial.println("Motor: off");
flag=1;
}
}
// if the state is '1' the motor will turn right
else if (state == '1') {
digitalWrite(motorPin1, LOW); // set pin 2 on L293D low
digitalWrite(motorPin2, HIGH); // set pin 7 on L293D high
if(flag == 0){
Serial.println("Motor: right");
flag=1;
}
}
// if the state is '2' the motor will turn left
else if (state == '2') {
digitalWrite(motorPin1, HIGH); // set pin 2 on L293D high
digitalWrite(motorPin2, LOW); // set pin 7 on L293D low
if(flag == 0){
Serial.println("Motor: left");
flag=1;
}
}
}
  Responder


Posibles temas similares…
Tema Autor Respuestas Vistas Último mensaje
  APORTE mp3 catalex y bluetooth hc 06 katxarix 0 873 18-04-2020, 10:20 AM
Último mensaje: katxarix
  CONSULTA AUMENTAR ALCANCE MÓDULO BLUETOOTH AT-09 CON ANTENA Alvaro Braca 3 2,704 14-03-2019, 09:12 AM
Último mensaje: Merenat
  APORTE Control de Persiana por bluetooth kuadri 0 1,467 16-06-2018, 11:33 PM
Último mensaje: kuadri
  Problema con bluetooth y comandos AT sejiozosky 41 17,481 06-05-2018, 11:48 AM
Último mensaje: Iván
  CONSULTA ayuda con modulo bluetooth f-6188 kcho26 0 1,405 25-02-2018, 07:29 PM
Último mensaje: kcho26