I am working with the arduino uno and an HC-06 bluetooth module. My project is for my job and in the end will control the processes of a laser cutting head. basically we have an app that is the "control panel" and controls the arduino. the arduino then controls a PLC which then is sent elsewhere to sensors and the laser. I have the basics done I think but I am stuck trying to figure out how to make the arduino read if there is an error in the system and show a notice message on the app. Also in the app there is a numbers only text box that will be used to manually send measurments to tell the laser where to be. I have no idea how i would write that in arduino. Any help is useful. Here is my code so far...
int x0 = 13;
int x1 = 12;
int x2 = 11;
int x3 = 10;
int x4 = 9;
int y5 = A0;
void setup()
{
Serial.begin(9600);
pinMode(x0, OUTPUT);
pinMode(x1, OUTPUT);
pinMode(x2, OUTPUT);
pinMode(x3, OUTPUT);
pinMode(x4, OUTPUT);
digitalWrite(x0, LOW);
digitalWrite(x1, LOW);
digitalWrite(x2, LOW);
digitalWrite(x3, LOW);
digitalWrite(x4, LOW);
}
void loop()
{
delay(100);
String t;
while(Serial.available()) {
t += (char)Serial.read();
}
if(t.length()){
if(t == "pp on") {
digitalWrite(x2, HIGH);
digitalWrite(x0,LOW);
digitalWrite(x1,LOW);
digitalWrite(x3, LOW);
digitalWrite(x4, LOW);
}
else if (t == "pp off") {
digitalWrite(x2, LOW);
}
if(t == "auto on") {
digitalWrite(x0, HIGH);
digitalWrite(x1,LOW);
digitalWrite(x2, LOW);
digitalWrite(x3, LOW);
digitalWrite(x4, LOW);
}
else if (t == "auto off") {
digitalWrite(x0, LOW);
}
if(t == "man on") {
digitalWrite(x1, HIGH);
digitalWrite(x0, LOW);
digitalWrite(x2, LOW);
}
else if (t == "man off") {
digitalWrite(x1, LOW);
}
if (t == "up on"){
digitalWrite(x3, HIGH);
digitalWrite(x1,HIGH);
digitalWrite(x0, LOW);
digitalWrite(x2, LOW);
}
else if(t == "up off"){
digitalWrite(x3, LOW);
digitalWrite(x1, LOW);
}
if (t == "down on"){
digitalWrite(x4, HIGH);
digitalWrite(x1, HIGH);
digitalWrite(x0, LOW);
digitalWrite(x2, LOW);
}
else if(t == "down off"){
digitalWrite(x4, LOW);
digitalWrite(x1, LOW);
}
}
}
If anyone has any segestions on how to make my code i have already better or more simple let me know as well.
the app is through MIT app inventor 2 if anyone can help on that end it would be much appreciated. heres a screen shot of what it looks like for visual use...