Using HC-05 for motor control on Arduino Leonardo

조회 수: 4 (최근 30일)
Bao Kang Hee
Bao Kang Hee 2016년 1월 31일
편집: Bao Kang Hee 2016년 1월 31일
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!

답변 (0개)

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

Help CenterFile Exchange에서 Automated Driving Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by