My Bluetooth instructions are sent to the Serial Monitor and not as a variable

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);
  }      
}


Welcome to the forum

Are you sure that you have posted the correct sketch ?

I ask because nowhere in your sketch do you output anything to the Serial monitor

1 Like

Single quotes for single characters

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.