Using HC-05 for motor control on Arduino Leonardo

5 visualizzazioni (ultimi 30 giorni)
Hi all, I have got a 3 Wheeled omni robot that is using Leonardo board and would like to control the motor movement via Bluetooth (HC-05). Below is the sketch uploaded into the Arduino:
//Standard PWM DC control
int E1 = 5; //M1 Speed Control
int E2 = 6; //M2 Speed Control
int E3 = 11; //M3 Speed Control
int M1 = 4; //M1 Direction Control
int M2 = 7; //M2 Direction Control
int M3 = 9; //M3 Direction Control
int val = 0;
void setup(void)
{
Serial1.begin(9600);
}
void loop()
{
if(Serial1.available() > 0){
val = Serial1.read();
switch(val)
{
if (val==1)
{
analogWrite(E1,HIGH);
}
if (val==0)
{
analogWrite(E1,LOW);
}
}
}
}
Below is my code for Matlab to enable Motor 3 to run when I enter 1 or 0.
b = Bluetooth ('HC-05',1);
fopen(b);
fwrite(b,1);
I am positive that all my wiring is connected properly. RX and TX on hc-05 are connected to Tx and Rx on Leonardo respectively.
Question is that I could not get any response from the robot at all. I am lost!
Please Help!

Risposte (0)

Community

Più risposte nel  Power Electronics Control

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by