I am creating a program for my Arduino mega with L293D Motor shield and bluetooth Module at rx pin for my arduino rc car project.
#include <AFMotor.h> #include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11); // RX, TX
AF_DCMotor motor1(3);
AF_DCMotor motor2(4);
char intra = '0';
void setup()
{
// set the data rate for the SoftwareSerial port
motor1.setSpeed(200);
mySerial.begin(9600);
}
void loop() // run over and over
{
if(mySerial.available()>0) {
intra = mySerial.read();
mySerial.write(intra);
}
if(intra == '1'){
up();
}
}
void up(){
motor1.run(FORWARD);
}
So the problem is basically the if statement not getting executed when i send a char '1'.
The serial monitor shows the input '1' but the motor doesnot respond.
I am creating a program for my Arduino mega with L293D Motor shield and bluetooth Module at rx pin for my arduino rc car project.
#include <AFMotor.h> #include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11); // RX, TX
AF_DCMotor motor1(3);
AF_DCMotor motor2(4);
char intra = '0';
void setup()
{
// set the data rate for the SoftwareSerial port
motor1.setSpeed(200);
mySerial.begin(9600);
}
void loop() // run over and over
{
if(mySerial.available()>0) {
intra = mySerial.read();
mySerial.write(intra);
}
if(intra == '1'){
up();
}
}
void up(){
motor1.run(FORWARD);
}
So the problem is basically the if statement not getting executed when i send a char '1'.
The serial monitor shows the input '1' but the motor doesnot respond.