Boa tarde pessoal, venho aqui pedir humildemente a ajuda de vocês para um trabalho de faculdade e como é tudo muito urgente (para amanhã!!) vou ser o mais breve possível e peço desculpas desde já se por acaso vir a infringir qualquer norma do fórum.

O objetivo era fazer um carro elétrico com função de ir para frente e para trás, virar direita e esquerda , ligar e desligar 2 leds tudo isso via Bluetooth.

O problema é que quando enviamos as letras pelo monitor serial os motores executam a sua função mas por algum motivo isso não acontece quando feito no app (Arduino Bluetooth RC Car).

PS:o app e o BT se pareiam(pelo menos os leds do mudulo e do app dizem isso).

utilizamos os seguintes componentes:

-Arduíno Uno R3

-Motor Shield Ponte h L293d

-Módulo Bluetooth HC-05

-2 motores

e conectamos da seguinte forma:

BT       Jumper             Placa

RX       laranja             RX

TX        preto               TX

Gnd      verde              Gnd

Vcc      branco            3,3V

segue fotos das ligaçoes:

IMG_2937.JPG

IMG_2943.JPG

IMG_2942.JPG

Programação( retirada da internet e disponível em http://wirebeings.com/Android-RC-CAR.html

//---------------------------------------------------------------------------------------------------------------------------------------
//Basic Remote Control Car - Bill Tarpy - North East CoderDojo 17/01/2015
//Feel free to use this software as a basis for your own. 
#include <SoftwareSerial.h> //the library for seial communication
#include <AFMotor.h> // the library for the Adafruit L293 Arduino Motor Shield
int incomingByte = 0; // for incoming serial data
int speed_min = 135; //the minimum "speed" the motors will turn - take it lower and motors don't turn
int speed_max = 255; //the maximum "speed" the motors will turn – you can’t put in higher

int speed_left = speed_max; // set both motors to maximum speed
int speed_right = speed_max;

//as we added a Motor Shield Library we can just use the following code to define our M1 and M2 motors and their PWM frequency
//the library takes care of all the complexity of the physical interface the Arduino uses to talk to the shield and the motor
AF_DCMotor motor_left(1, MOTOR12_1KHZ); // create motor #1, 1KHz pwm
AF_DCMotor motor_right(4, MOTOR12_1KHZ); // create motor #2, 1KHz pwm

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps - this is the speed the serial interface will work at
Serial.println("");// display message for test purposes when connected to a serial monitor 
}

void loop() {
//this is our repeating loop - that will go round and round until we switch the Arduino off
motor_left.setSpeed(speed_left); // minimum speed 135 max speed 255
motor_right.setSpeed(speed_right); // minimum speed 135 max speed 255

//first check if there is anything on the serial interface
//we are using the Arduino's default serial interface (pins 0 and 1)so no need to define these
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
}

// if there is something on the serial interface it is read and assigned to incomingByte
// we then use a SWITCH (case) statement which, depending on incomingByte, does different things
// it runs the left and right motors to produce movement Forward, Backward, Left, Right or Stop
//that's all there is to it!

switch(incomingByte)
{
case 'S':
// stop all motors
{ motor_left.run(RELEASE); // stopped
motor_right.run(RELEASE); // stopped
Serial.println("Stop\n"); //display message for test purposes when connected to a serial monitor
incomingByte='*';}

break;

case 'F':
// turn it on going forward
{ motor_left.run(FORWARD);

Serial.println("Forward\n");//display message for test purposes when connected to a serial monitor
incomingByte='*';}
break;

case 'B':
// turn it on going backward
{ motor_left.run(BACKWARD);

Serial.println("Backward\n");//display message for test purposes when connected to a serial monitor
incomingByte='*';}
break;

case 'R':
// turn right

motor_right.run(FORWARD); 
Serial.println("Rotate Right\n");//display message for test purposes
incomingByte='*';}
break;

case 'L':
// turn left

motor_right.run(BACKWARD); 
Serial.println("Rotate Left\n");//display message for test purposes
incomingByte='*';}
break;

case '1':
// Put what you like in here - for example - change the motor speeds
{ speed_left = speed_min; // set both motors to minimum speed
speed_right = speed_min;
Serial.println("Speed 1\n");//display message for test purposes
incomingByte='*';}
break;

case '2':
// Put what you like in here - for example - turn on some LED lights on the car

Serial.println("Lights on\n");//display message for test purposes

//why not use the motor sheild's spre motors - M3 and M4 - to turn lights on and off
//you would need to define M3/4 in your program setup, and a few extra veriables to hold values
//then FORWARD and BACKWARD would send a voltage one way then the other through the M3 and M4 terminals as you require

incomingByte='*';}
break; 
}
}

se por acaso alguem puder me ajudar a apontar e corrigir os erros a tempo eu serei muito grato.

Exibições: 1663

Responder esta

Respostas a este tópico

As ligações com o modulo Bluetooth parecem estar incorretas. Confira com atenção inclusive o VCC e GND. 

O correto seria :

TX com RX  ( usa niveis 3,3V) 

RX com TX  ( usa niveis 3,3V) 

Usou os resistores de conversão de níveis ? 

Você seguiu esse exemplo ?

https://www.squirrel-labs.net/blog/basic-android-app-bluetooth-ardu...

eu pretendia seguir este exemplo:mas quando eu conectava dessa forma aparecia esse erro

entao decidi deixar RX--RX TX--TX

no exemplo ele diz para conectar o vcc na porta 5v mas eu coloquei na 3.3v pois no meu bluetooth tava escrito que era 3.3v (modulo bt que eu uso).

A ligação deve ser feita como o Gustavo falou:

RX do Arduino com o TX do BT e vice-versa.

A ligação em 3.3v está correta.

Esse erro que deu foi durante o upload do sketch para o Arduino.

Para corrigir, faça o seguinte:

Ao transferir o sketch, desconecte os cabos tx e rx.

Depois da transferência, conecte de novo.

O motivo é que o Arduino usa essas portas para fazer a transferência.

Para desligar o Modulo Bluetooth é só desconectar o fio VCC, enquanto estiver fazendo 

o upload do seu Sketch. 

Foi como vc disse José Augusto, eu upei para o arduino e troquei os fios

Tenho um modulo similar, mas não testei-o ainda. 

A tensão que esta escrita atrás do modulo é de 3,6V a 6V e não 3,3V. 

Não sei se ele funciona com somente 3,3V.

O diagrama que enviou esta identico ao meu :

RX com TX e TX com TX. 

Reveja as conexões que fez na sua montagem. 

Não pode conectar RX com RX e TX com TX.

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço