Hello,
I am trying to build a car controlled with the keyboard letters and wirelles communication through a RF 433Mhz module as shown in the images in attachment.
I am using a L298N H-brigde and controlling the car through the serial monitor in arduino (via direct USB connection by typing the letter i want in the monitor). The code so far is:
#define MOT_ESQ_FRENTE 5
#define MOT_ESQ_TRAS 6
#define MOT_DIR_FRENTE 10
#define MOT_DIR_TRAS 11
int val;
void setup()
{
Serial.begin(9600);
pinMode(MOT_ESQ_FRENTE,OUTPUT);
pinMode(MOT_ESQ_TRAS,OUTPUT);
pinMode(MOT_DIR_FRENTE,OUTPUT);
pinMode(MOT_DIR_TRAS,OUTPUT);
}
void loop()
{
if(Serial.available())
{
val = Serial.read();
switch(val)
{
case 'W':
analogWrite(MOT_ESQ_FRENTE,127);
analogWrite(MOT_DIR_FRENTE,127);
delay(125);
analogWrite(MOT_ESQ_FRENTE,0);
analogWrite(MOT_DIR_FRENTE,0);
break;
case 'A':
analogWrite(MOT_ESQ_TRAS,127);
analogWrite(MOT_DIR_FRENTE,127);
delay(125);
analogWrite(MOT_ESQ_TRAS,0);
analogWrite(MOT_DIR_FRENTE,0);
break;
case 'S':
analogWrite(MOT_ESQ_TRAS,127);
analogWrite(MOT_DIR_TRAS,127);
delay(125);
analogWrite(MOT_ESQ_TRAS,0);
analogWrite(MOT_DIR_TRAS,0);
break;
case 'D':
analogWrite(MOT_ESQ_FRENTE,127);
analogWrite(MOT_DIR_TRAS,127);
delay(125);
analogWrite(MOT_ESQ_FRENTE,0);
analogWrite(MOT_DIR_TRAS,0);
break;
}
}
}
It works perfectly, but only if I use the USB connection. When i try to load the code in the RF module, by connecting the ground module to a USB port with no longer USB-Arduino connection, and the air module to Arduino (i only connected the RX arduino pin to the TX module pin and vice-versa, did not change the code), the sketch doesn't load nor find the board. I've tried to change the baud to a higher value, didn't work. Tried to first load it to the Arduino via USB, then connect the RF module (and set the serial monitor to the COM correspondent to the module), and nothing.
I've also tried to use the software serial library, and selected the pins 2 and 3 to be the RX and TX connections. Changed the code informations to "mySerial" and etc. Did not work either.
Can someone give me a hand on how i can make this serial communication work?


