Hi, I'm currently doing an school project with Arduino and one of the things that I have to do is connect an HC-05 with my phone to control things.
I have done a program with an online tutorial to control two leds. On my phone im using an app called Serial Bluetooth Terminal.
The problem I have is that whenever I write something and send it with my app, it always shows in the Serial Monitor and not as a variable as I have written in the code. Can someone help me?
Here's my code:
#include <SoftwareSerial.h>
SoftwareSerial miBT(10,11); // Makes pins 10 and 11, RX and TX
char DATA = 0;
int LEDL = 2;
int LEDR = 3;
void setup() {
Serial.begin(9600);
miBT.begin(38400);
pinMode(LEDL,OUTPUT);
pinMode(LEDR,OUTPUT);
}
void loop() {
if (miBT.available()) {
DATA = miBT.read();
if (DATA == "1")
digitalWrite (LEDL, HIGH);
if (DATA == '2')
digitalWrite (LEDL, LOW);
if (DATA == '3')
digitalWrite (LEDR, HIGH);
if (DATA == '4')
digitalWrite (LEDR, LOW);
}
}