Smartphone Controlled BT Relay Module Issues w/ App Inventor

Hello,

I have a project using an Uno board, Sainsmart 16 relay module and an HC-05 BT module, controlled by an MIT App Inventor app.

I'm learning to create a phone app, while simultaneously learning Arduino coding, which is controlling a small machine I'm building that has electric motors, hydraulic valves, etc. I'm using App Inventor to create the app which appears to be working properly. But, I can't get the 16 relay module to trigger relays properly, actually they aren't triggering at all.

My app simply sends a letter value(A,a,B,b....etc.), to the Uno, to turn on/off relays.
Being new to Arduino, I've scoured many sources to resolve what I'm doing wrong in my code but have had no luck. I've successfully operated two relays but have since made changes to add the other relays and have messed something up. If someone could point out the mistakes I've made, I would be greatly appreciative.

The relay board has a 12v supply to operate the relays, 5v jumpered from the Uno to the relay module and to the HC-05. Output pins are jumpered from the Uno to the relay module.

I can establish connection from my phone to the BT module but then nothing happens when I hold buttons on my phone. Sorry if I haven't worded everything properly... :cry:

Example of phone app :

And my code:

char Incoming_value = 'A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,J,j,K,k,L,l,M,m,N,n,P,p,Q,q,R,r'; // Values to be received from smartphone app via HC-05 BT module.
//Motor functions will be operated with directional buttons within MIT App Inventor App and send values to Arduino Uno board.
//Sainsmart 16 module relay board has 12v power connected as well as jumpers from Uno to Relay module as noted in String Function.

String inputs;
#define relay1 2 //Connect relay1 to pin 2
#define relay2 3 //Connect relay2 to pin 3
#define relay3 4 //Connect relay3 to pin 4
#define relay4 5 //Connect relay4 to pin 5
#define relay5 6 //Connect relay5 to pin 6
#define relay6 7 //Connect relay6 to pin 7
#define relay7 8 //Connect relay7 to pin 8
#define relay8 9 //Connect relay8 to pin 9
#define relay9 10 //Connect relay9 to pin 10
#define relay10 11 //Connect relay10 to pin 11
#define relay11 12 //Connect relay11 to pin 12
#define relay12 13 //Connect relay12 to pin 13
#define relay13 A0 //Connect relay13 to pin A0
#define relay14 A1 //Connect relay13 to pin A1
#define relay15 A2 //Connect relay13 to pin A2
#define relay16 A3 //Connect relay13 to pin A3

void setup()

{
  Serial.begin(9600);
  pinMode(relay1, OUTPUT);   //Set pins as outputs
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(relay5, OUTPUT);
  pinMode(relay6, OUTPUT);
  pinMode(relay7, OUTPUT);
  pinMode(relay8, OUTPUT);
  pinMode(relay9, OUTPUT);
  pinMode(relay10, OUTPUT);
  pinMode(relay11, OUTPUT);
  pinMode(relay12, OUTPUT);
  pinMode(relay13, OUTPUT);
  pinMode(relay14, OUTPUT);
  pinMode(relay15, OUTPUT);
  pinMode(relay16, OUTPUT);


  digitalWrite(relay1, HIGH); //Switch relay1 off
  digitalWrite(relay2, HIGH); //Swtich relay2 off
  digitalWrite(relay3, HIGH); //Switch relay3 off
  digitalWrite(relay4, HIGH); //Swtich relay4 off
  digitalWrite(relay5, HIGH); //Switch relay5 off
  digitalWrite(relay6, HIGH); //Swtich relay6 off
  digitalWrite(relay7, HIGH); //Switch relay7 off
  digitalWrite(relay8, HIGH); //Swtich relay8 off
  digitalWrite(relay9, HIGH); //Swtich relay9 off
  digitalWrite(relay10, HIGH); //Swtich relay10 off
  digitalWrite(relay11, HIGH); //Swtich relay11 off
  digitalWrite(relay12, HIGH); //Swtich relay12 off
  digitalWrite(relay13, HIGH); //Swtich relay13 off
  digitalWrite(relay14, HIGH); //Swtich relay14 off
  digitalWrite(relay15, HIGH); //Swtich relay15 off
  digitalWrite(relay16, HIGH); //Swtich relay16 off
}

void loop()
{
  if (Serial.available() > 0)
  {
    Incoming_value = Serial.read();  //Using If Function to switch relays on/off.
    Serial.print(Incoming_value);
    Serial.print("\n"); {
      if (Incoming_value == 'A')
        digitalWrite(relay1, LOW);
      else if (Incoming_value == 'a')
        digitalWrite(relay1, HIGH); {
        if (Incoming_value == 'A')
          Serial.println("Engine Starting");
        else Serial.println("Engine Start Released");
      }
    }
    if (Incoming_value == 'B')
      digitalWrite(relay2, LOW);
    else if (Incoming_value == 'b')
      digitalWrite(relay2, HIGH); {
      if (Incoming_value == 'B')
        Serial.println("Engine Relay Engaged");
      else Serial.println("Engine Relay Disengaged");
    }
    if (Incoming_value == 'C')
      digitalWrite(relay3, LOW);
    else if (Incoming_value == 'c')
      digitalWrite(relay3, HIGH); {
      if (Incoming_value == 'C')
        Serial.println("Engine High Rpm");
      else Serial.println("Engine Low Rpm");
}

You code is kinda messy, and your logic is not working properly.

I've got the freedom to remake your logic, and added a function to check wheter the code received is valid or not.

char Incoming_value = 'A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,J,j,K,k,L,l,M,m,N,n,P,p,Q,q,R,r'; // Values to be received from smartphone app via HC-05 BT module.
//Motor functions will be operated with directional buttons within MIT App Inventor App and send values to Arduino Uno board.
//Sainsmart 16 module relay board has 12v power connected as well as jumpers from Uno to Relay module as noted in String Function.

String inputs;
#define relay1 2 //Connect relay1 to pin 2
#define relay2 3 //Connect relay2 to pin 3
#define relay3 4 //Connect relay3 to pin 4
#define relay4 5 //Connect relay4 to pin 5
#define relay5 6 //Connect relay5 to pin 6
#define relay6 7 //Connect relay6 to pin 7
#define relay7 8 //Connect relay7 to pin 8
#define relay8 9 //Connect relay8 to pin 9
#define relay9 10 //Connect relay9 to pin 10
#define relay10 11 //Connect relay10 to pin 11
#define relay11 12 //Connect relay11 to pin 12
#define relay12 13 //Connect relay12 to pin 13
#define relay13 A0 //Connect relay13 to pin A0
#define relay14 A1 //Connect relay13 to pin A1
#define relay15 A2 //Connect relay13 to pin A2
#define relay16 A3 //Connect relay13 to pin A3

void setup()

{
  Serial.begin(9600);
  pinMode(relay1, OUTPUT);   //Set pins as outputs
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(relay5, OUTPUT);
  pinMode(relay6, OUTPUT);
  pinMode(relay7, OUTPUT);
  pinMode(relay8, OUTPUT);
  pinMode(relay9, OUTPUT);
  pinMode(relay10, OUTPUT);
  pinMode(relay11, OUTPUT);
  pinMode(relay12, OUTPUT);
  pinMode(relay13, OUTPUT);
  pinMode(relay14, OUTPUT);
  pinMode(relay15, OUTPUT);
  pinMode(relay16, OUTPUT);


  digitalWrite(relay1, HIGH); //Switch relay1 off
  digitalWrite(relay2, HIGH); //Swtich relay2 off
  digitalWrite(relay3, HIGH); //Switch relay3 off
  digitalWrite(relay4, HIGH); //Swtich relay4 off
  digitalWrite(relay5, HIGH); //Switch relay5 off
  digitalWrite(relay6, HIGH); //Swtich relay6 off
  digitalWrite(relay7, HIGH); //Switch relay7 off
  digitalWrite(relay8, HIGH); //Swtich relay8 off
  digitalWrite(relay9, HIGH); //Swtich relay9 off
  digitalWrite(relay10, HIGH); //Swtich relay10 off
  digitalWrite(relay11, HIGH); //Swtich relay11 off
  digitalWrite(relay12, HIGH); //Swtich relay12 off
  digitalWrite(relay13, HIGH); //Swtich relay13 off
  digitalWrite(relay14, HIGH); //Swtich relay14 off
  digitalWrite(relay15, HIGH); //Swtich relay15 off
  digitalWrite(relay16, HIGH); //Swtich relay16 off
}

void loop()
{
  if (Serial.available() > 0)
  {
    Incoming_value = Serial.read();  //Using If Function to switch relays on/off.
    
    if(!validLetter(Incoming_value))
      return;

    Serial.print("Received: ");
    Serial.print(Incoming_value);
    Serial.print("\n");
    
    if(Incoming_value == 'A')
    {
        digitalWrite(relay1, LOW);
        Serial.println("Engine Starting");
    }
    else if(Incoming_value == 'a')
    {
        digitalWrite(relay1, HIGH);
        Serial.println("Engine Start Released");
    }
    else if(Incoming_value == 'B')
    {
        digitalWrite(relay2, LOW);
        Serial.println("Engine Relay Engaged");
    }
    else if(Incoming_value == 'b')
    {
        digitalWrite(relay2, HIGH);
        Serial.println("Engine Relay Disengaged");
    }
    else if(Incoming_value == 'C')
    {
        digitalWrite(relay2, LOW);
        Serial.println("Engine High Rpm");
    }
    else if(Incoming_value == 'c')
    {
        digitalWrite(relay2, HIGH);
        Serial.println("Engine Low Rpm");
    }
  }
}

char letters[] = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrR";

bool validLetter(char value)
{
  for(int i = 0; i < sizeof letters; ++i)
  {
    if(value == letters[i])
      return true; 
  }
  return false;
}

Please take some time to read it, and if you don't get something, please ask. You'll have to add the other letters.

It is working properly now with the serial monitor presented in arduino ide, try with your bluetooth.

If it stills doesn't works, it is likely the blueetooth module not working properly.

Lemme know your results!

I sincerely appreciate you taking the time to organize and fix my code. And, after seeing your work, I would agree that what I had was seriously ugly. I know I still have a lot to learn about programming... Thank you!

Uploading the new code seems to work great with the serial monitor but I still can't get the app to make the relays engage. I guess I'm going to have to swap out BT modules again to see if it will work. I do know that I was able to get 2 relays to work( I only had 2 programmed at the time) with this module but I had different code.

I guess I will have to continue to figure out why I've only been able to get my phone to operate the relay module successfully one time. I was assuming that maybe Arduino wasn't liking the letters. Oh well, I will keep learning and hopefully get it resolved. Thank you again for helping!

Don't worry, writing cleaner (and hopefully faster) codes comes with time and practice.

May I ask which module you're using and how are you making the connections?

This way I can help you with better.

Edit:

Nevermind, you are using HC-05 as your bluetooth module.

I can see in your code that you should be using digital pins 0 and 1 as RX and TX, correct?

If you are using this, i'm afraid you can't use the serial monitor at the same you're using the module, and this maybe is the cause.

Alternatively, you should use the SoftwareSerial library https://www.arduino.cc/en/Reference/softwareSerial.

Then you will be free to use the serial monitor.

Here goes an example (untested, cause i don't have any RX,TX module):

// Please don't forget to include the library
#include <SoftwareSerial.h>
    
// Pins which are gonna be use for serial communication
SoftwareSerial bluetoothSerial(10, 11); // RX, TX    
    
void setup()   
{  
  Serial.begin(9600); // Default arduino serial, for usage with serial monitor.  
  bluetoothSerial.begin(9600); // Begins the serial for the blueetooth module.
}  
    
void loop()  
{  
  // Notice how it has the same sintaxe as the standard serial object.
  if(bluetoothSerial.available()) 
  {
    Serial.println("The is something on the serial bluetooth buffer");  
    Serial.println(bluetoothSerial.read());
  }  
}

Share the results!!!

I can see in your code that you should be using digital pins 0 and 1 as RX and TX, correct?

If you are using this, i'm afraid you can't use the serial monitor at the same you're using the module, and this maybe is the cause.

Not totally correct. To download code to the board, the RX and TX connection to the BT module will need to be disconnected.

When the download is completed and the module is connected back, the Arduino can only read Serial from the BT module but can write Serial to both the serial monitor and the BT module.

In many applications, the use of hardware serial with the HC05 is to be preferred.

Hi.
You haven't told us what you see on the monitor in response to pressing the phone app buttons. Do you get the letters that you intend?

You can use a BT serial terminal app on your phone to send the commands. This removes your custom app from the equation.

I use the "when button.click" block to send commands. Haven't used the TouchUp & TouchDown blocks.

If the commands are appearing on the monitor then the HC-05 module is working.

John.

cattledog:
Not totally correct. To download code to the board, the RX and TX connection to the BT module will need to be disconnected.

When the download is completed and the module is connected back, the Arduino can only read Serial from the BT module but can write Serial to both the serial monitor and the BT module.

In many applications, the use of hardware serial with the HC05 is to be preferred.

Cattledog:
Thank you for pointing out the BT module needs to be disconnected but unfortunately I've already been doing that with each new download. Your mention of the Uno only being able to read from the BT module once reconnected has me curious tho. Like I've already said, I can't get my phone app to fire relays, once I reconnect the RX TX wires and connect my phone via BT. But, when I open the serial monitor, I'm able to manually type in the characters( same as my phone app is using), and the relay module will toggle the relays respectively. If the Uno will only receive serial via bluetooth once it's reconnected, how can this happen?

Hillmanlmp:
I will find a BT serial terminal app and try as you've suggested, thank you. I've had success(once) with using the TouchUp & TouchDown blocks until I started adding other functions to the code. The monitor remains blank when trying to use my app but if I manually type in a character, it displays it on the monitor and performs the function. I guess I've messed something up with my phone app but I've watched many tutorials to try and ensure I'm doing it properly.

I'll attach a couple pictures of my App Inventor screen layout and block layout to maybe give an idea of what my app is doing...or supposed to do.

Your mention of the Uno only being able to read from the BT module once reconnected has me curious tho. Like I've already said, I can't get my phone app to fire relays, once I reconnect the RX TX wires and connect my phone via BT. But, when I open the serial monitor, I'm able to manually type in the characters( same as my phone app is using), and the relay module will toggle the relays respectively. If the Uno will only receive serial via bluetooth once it's reconnected, how can this happen?

My guess is that you do not have the RX and TX connected properly from the module to the Arduino. Try reversing the connections. This may also be why the phone does not operate the relays.

As I said, when the module is connected to the Serial port of the Uno, the monitor can only read. This is my test sketch with the BT on the Serial connection. With the monitor and a standard phone terminal app I can see what responds and what doesn't.

// connect HC05 Vcc to 5V, GND to GND
// Disconnect HC05 RX and TX and download program  over usb
// When download complete
// connect HC05 module TX to D0 (Arduino RX)
// connect HC05 module RX via voltage divide to D1(Arduino TX) 

void setup()  
{
  // set digital pin to control as an output
  pinMode(13, OUTPUT);
  // set the data rate for the Serial port
  Serial.begin(9600);
  // Send test message to other device
  Serial.println("Hello from Arduino");
}
char a; // stores incoming character from other device
void loop() 
{
  if (Serial.available())
  // if text arrived in from Serial serial...
  {
    a=(Serial.read());
    if (a=='1')
    {
      digitalWrite(13, HIGH);
      Serial.println("LED on");
    }
    if (a=='2')
    {
      digitalWrite(13, LOW);
      Serial.println("LED off");
    }
    if (a=='?')
    {
      Serial.println("Send '1' to turn LED on");
      Serial.println("Send '2' to turn LED off");
    }   
    // you can add more "if" statements with other characters to add more commands
  }
}

cattledog:
My guess is that you do not have the RX and TX connected properly from the module to the Arduino. Try reversing the connections. This may also be why the phone does not operate the relays.

As I said, when the module is connected to the Serial port of the Uno, the monitor can only read. This is my test sketch with the BT on the Serial connection. With the monitor and a standard phone terminal app I can see what responds and what doesn't.

I did as you instructed and with your program I was no longer able to use the monitor to send values, but I assure you that I was with the program that I originally had and the one electricsolder96 kindly fixed for me. The weird part is, with the prgm i had, when i would type a command in the monitor, the relay would actuate and the free BT serial terminal I installed on my phone would VTT the println text from the program.

So, with my previous program running on Uno, I had my phone connected to BT module, the BT Terminal FREE app pulled up on my phone, the uno connected via usb and the serial monitor open in Arduino. Typing A's, a's or any other letter into the "string to send" field on the phone app, did nothing. But, in the arduino monitor, when I would type an A, a, etc... the phone app would read and display what my program had in the println section. After downloading your program, I used the monitor to send a, b, 1, 2, nothing happened, at all, neither on the BT Terminal FREE app, nor in the monitor.

I am pretty versed in several trades, including cnc machine repair, electronics repair, so I have a general understanding what's going on but this coding and serial communication is kicking my butt...I'm going to grab yet another BT module and swap it out in hopes it's a hardware issue, might even try another Uno. I appreciate all your help thus far and apologize for any frustration due to my ignorance...

I did as you instructed and with your program I was no longer able to use the monitor to send values, but I assure you that I was with the program that I originally had and the one electricsolder96 kindly fixed for me.

Have you posted this "original" program? Perhaps it was using software serial between the BT module and the arduino?

I recommend Kai Morich's Serial Bluetooth Terminal as a phone app. It is very important to get your program running properly with a standard terminal app before working on the custom app inventor app.

So, with my previous program running on Uno, I had my phone connected to BT module, the BT Terminal FREE app pulled up on my phone, the uno connected via usb and the serial monitor open in Arduino. Typing A's, a's or any other letter into the "string to send" field on the phone app, did nothing. But, in the arduino monitor, when I would type an A, a, etc... the phone app would read and display what my program had in the println section

I would suspect the connection between the module TX and the Aduino RX or as you say possibly a defective HC05.

With the Bluetooth HC05 TX disconnected from pin 0, the test program behaves as you state. The phone does nothing on sending, but will receive and echo the monitor command. The monitor through USB will send and receive and control the led when pin 0 is not connected.

You've done well to come this far without prior knowledge. You're tackling a few different things and I'm sure the others will agree that it's good practice to get some mastery of each one individually before cobbling them all together in a project & hoping it all works. You'll get there. Rest assured we all get stumped by seemingly intractable problems.

It's great to have two of everything so you can swap out a suspect device, but I think it's too soon to blame the HC-05. Hardware is reliable. Our efforts in programming and physical assembly are less so. If you do swap out the HC-05 and things still don't work you will have learned nothing. You have to prove things work.

I use a TTL/USB converter to test an HC-05. This connects the HC-05 to a PC's USB port. Then your phone can communicate with the IDE monitor. No custom software needed.

Try putting the HC-05 on a pair of digital pins other than pins 0 & 1, and use software serial. This might not be your ideal but you will need to get a grasp of both h/w & s/w serial comms.

Heed cattledog's advice to issue the commands from a BT serial terminal app for now. You will often need to come back to using the terminal app.

I don't follow all the logic in your app. When you touch the start button, "A" is sent, immediately followed by "B". When you remove your finger "a" is sent. Maybe that is what you want, but it confuses me. I use the "when button.clicked" block. When I tap the button, a text string is sent, such as "SIM_ON". Simple.

It is a great help to use commands that express their intent. "A" "B" "c".... will work, but "ENG_GO" "ENG_STOP" "RPM_HI" "RPM_LO" are much easier to work with in writing the code and troubleshooting. Your sketch would need to capture a text string, not just a single character. Not hard.

Explore "case" as an alternative to "if...then...else..." statements.

In your app I don't think you need worry about continually testing the BT connection at this stage of the project. Just assume the best.

App Inventor apps can grow into hideous things. Go slowly, clean things up, get rid of fanciful features and name things meaningfully. Backup often. Writing an Arduino sketch and building an App Inventor app are both programming, but in very different ways. Both demand planning & discipline. Don't think app building is child's play.

Good luck,
John.

HillmanImp:
You've done well to come this far without prior knowledge. You're tackling a few different things and I'm sure the others will agree that it's good practice to get some mastery of each one individually before cobbling them all together in a project & hoping it all works. You'll get there. Rest assured we all get stumped by seemingly intractable problems.

Thank you John, for the kind words regarding my efforts thus far. Working 90 hrs/wk on top of learning to create an app and learn to code is quite daunting at times. Tho, my philosophy is that there is no "try", there is "do" or "do not" and I'm determined to "do" this project to completion.
I also appreciate all your helpful suggestions such as using sensible commands but due to my ignorance, single characters is what I assumed I needed to use based on all the simple tutorials I've watched on other projects. I will definitely look into using a text string in the future as my method is proving difficult to troubleshoot. And, your suggestion for looking into serial comms led me to learn serial in a way that makes sense. Very helpful. I'm going to look into "case" as an alternative as well.

I don't follow all the logic in your app. When you touch the start button, "A" is sent, immediately followed by "B". When you remove your finger "a" is sent. Maybe that is what you want, but it confuses me. I use the "when button.clicked" block. When I tap the button, a text string is sent, such as "SIM_ON". Simple.

I'm using capital "A,B,etc." to turn on a relay, and lowercase "a,b,etc." to turn off a relay. Some relays I want to latch and some I want to me momentary. I use the button.click for the "latched" relays that would keep a valve open per say, but use button.TouchDown for linear actuators that I don't want to run away; only moving while my finger is on the button. I hope that makes sense.

cattledog:
I recommend Kai Morich's Serial Bluetooth Terminal as a phone app. It is very important to get your program running properly with a standard terminal app before working on the custom app inventor app.

https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal&hl=en_US&gl=US

Cattledog, Thank you for your feedback and suggestions. It seems that my HC-05 was part of the culprit here at least. I swapped out with a different one and everything seems to be working properly. I have deduced this by switching out modules, connecting to my phone, then using the BT terminal app to send commands. Multiple attempts proved that the original module just won't work properly. I don't know if it's worth pursuing the "why", but will just run with the one that's working for now.

Another potential issue I came across was a reccurent error while trying to upload different sketches to the Uno. The dreaded "avrdude: ser_open(): can't open device "\.\COM2": Access is denied.". After multiple attempts to write rules to open the port, restarting pc, resetting Uno...I finally started fidgeting with my usb cable; flexing it in different directions then hitting the upload button in Arduino IDE. I found a certain position the cable needed to be in for a successful upload. I tried 2 different cables and had the same situation. I'm not sure if some bits were being lost up till finding this issue or if that's even a thing.

Either way, I think I'm up and going now thanks to your guys' help and I can't say thank you enough! I'm sure we'll chatting in the future as I plan to add laser measuring devices, readouts, etc. to my project eventually. Thanks again!

I think I'm up and going now

Well done :slight_smile:

It seems that my HC-05 was part of the culprit here at least. I swapped out with a different one and everything seems to be working properly.

If you were using those double ended breadboard wires for connections, they are often faulty and should be change as a first trouble shooting effort. I'm fairly certain that your hardware issue was the connection between the module TX and the Arduino RX or a defective module relating to the wireless receiving and pushing it out the TX.

In your study of Serial communications, I strongly recommend that you study and incorporate the methods of this excellent tutorial by Robin2. Serial Input Basics.
https://forum.arduino.cc/index.php?topic=396450.0

cattledog:
If you were using those double ended breadboard wires for connections, they are often faulty and should be change as a first trouble shooting effort. I'm fairly certain that your hardware issue was the connection between the module TX and the Arduino RX or a defective module relating to the wireless receiving and pushing it out the TX.

I am using the breadboard wires for connection so you had me curious...I plugged in the faulty module and sent a command from my phone. Meanwhile, I wiggled and flexed the connections on both the hc-05 and the Uno. I couldn't get the faulty module to do anything. I unplugged it and plugged in the "good" module and everything works without having to manipulate any connections. Oh, and I can see my inputs on the serial monitor as well now. I'm very ignorant to coding but my basic electrical skills tell me that a bad wire isn't the culprit...possibly a solder connection on the module but definitely not a jumper. I do appreciate you inspiring me to double check. :slight_smile: You guys are great and helped a ton. I read the link on serial inputs you shared. I have so much to learn about so many things! lol It's all interesting tho, and I'm always up for learning something new. Thank you!

Ahh, so that's why you use TouchDown and TouchUp. Clever. So now you're
giving us tips :smiley: . I might use it.

I was thinking about the conflict between the IDE monitor and the BT connected to the h/w serial port.

There's no reason why you can't use your phone app as a substitute for the monitor. In yr app, in every clock cycle read any text received by BT and put it in a label on the screen. There's a block -- I think it's TextBox -- where you can enter text and then you could send that to BT. Together these would be a substitute for the monitor or BT terminal app. Any debug messages you put in yr sketch would appear on the phone. I know this will work but I haven't put it together like that.

This is a good discussion. Helpful to more than yourself.

With yr carriage control, have a look at the Slider component. You would select a value with the slider & press a send button. I use this. I send a single byte integer. In the sketch I test if the incoming data is a single byte. If it is I treat it as a number and use it to set a parameter in the sketch.

I have two HC-05 modules that no longer work. My best guess is that I connected them the wrong way and 5v went where it shouldn't have.

John.

HillmanImp:
There's no reason why you can't use your phone app as a substitute for the monitor. In yr app, in every clock cycle read any text received by BT and put it in a label on the screen. There's a block -- I think it's TextBox -- where you can enter text and then you could send that to BT. Together these would be a substitute for the monitor or BT terminal app. Any debug messages you put in yr sketch would appear on the phone. I know this will work but I haven't put it together like that.

I never thought about having a label to show text for what's currently active; that's a great idea! Ideally it would eliminate the need for the serial monitor. Thank you.
After testing my controls from my phone, I ran into a, what could be catastrophic, undesirable scenario. It seems that if I press my app buttons in quick succession, my phone app freezes and any relays being held on at the time, remain on. So, if I'm jogging a motor per say, bumping it to a desired position, there is a possibility that the app will freeze and the relay remain on causing a runaway situation. Is there someway to detect this case and turn off all relays??? I have an emergency stop button on my app to shut off all relays but this button obviously won't work if the app is frozen. This is a major safety issue.

Is there someway to detect this case and turn off all relays???

For a start, there should be safety limit switches on the hardware to shut things down at the ends of travel.

I think that one way to deal with interrupted connections using software is to put a periodic simple heartbeat signal from the phone to the Arduino. I don't know what is the critical period for motor running, but perhaps a single character can be sent from the phone to the Arduino every 250 ms.

If the Arduino does not detect the heartbeat in a fixed time period, it can shut down what is running.

cattledog:
For a start, there should be safety limit switches on the hardware to shut things down at the ends of travel.

I think that one way to deal with interrupted connections using software is to put a periodic simple heartbeat signal from the phone to the Arduino. I don't know what is the critical period for motor running, but perhaps a single character can be sent from the phone to the Arduino every 250 ms.

If the Arduino does not detect the heartbeat in a fixed time period, it can shut down what is running.

I will have limit switches for sure but want to deter objects running into other objects...
I will look into what a heartbeat signal is, seems like a great solution! Thank you!

Don't overlook the possiblity of losing the BT connection.

I'd like to know what causes the app to freeze. I'll see how my app responds to rapid presses.

You need to determine if any characters are being sent even tho the app has frozen. Maybe it is continuously sending even tho the screen has frozen. You could have a label and have the app put any sent text in the label. It would be helpful if the sketch echoed any received text back to the phone in another label. You would then have confirmation that the sent text was received.

You might need a hardwired ESD on the machinery itself.

Don't overlook the possibility of losing the BT connection.

A lost connection can be handled through reading the STATE pin on the HC05.
https://forum.arduino.cc/index.php?topic=597070.0

If you are having any problems developing phone code which sends a heartbeat in order for you to develop heartbeat reading code on the Arduino, it is possible for you to use one of the standard bluetooth joystick phone apps which have periodic sending. Joystick apps are designed to constantly refresh the value sent.

For example