Hi everyone, I'm trying to set up an L298n to be able to control the speed of two DC motors (VIA BLUETOOTH), using an arduino UNO.
I created an MIT app inventor app and am trying to use the slider function on the app to control the motor speed. But when I open the serial monitor to see what is coming in from the HC05 that I have connected to the RX and TX pins on the arduino as well as the 5v and GND some gibberish comes up. I have attached an image of what the serial monitor produces and my MIT app inventor blocks. I have read that alot of people get this issue via baud rate but mine has already been changed to 34800.
Any help is greatly appreciated in solving this issue.
Here's the code:
int enA = 6;
int enB = 3;
int in1 = 4;
int in2 = 9;
int in3 = 8;
int in4 = 2;
int val2;
void setup() {
Serial.begin(38400);
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
digitalWrite (in1, HIGH);
digitalWrite (in2, LOW);
digitalWrite (in3, HIGH);
digitalWrite (in4, LOW);
}
void loop()
{
if (Serial.available() >= 0 )
{
unsigned int a = Serial.read();
unsigned int b = Serial.read();
unsigned int val = (b * 256) + a;
Serial.println(val);
if (val >= 0 && val <= 255)
{
analogWrite(enA, val);
}
if (val >= 1000 && val <= 1255)
{
val2 = val - 1000;
analogWrite(enB, val2);
}
}
}
}

