I have a program I am writing that is throwing numerous errors. Basically I have an arduino Mega that is connected to an Ethernet shield, and it is responsible for opening and closing multiple drawers/doors in an escape room. I am trying to simplify the coding by using variables and loops as needed. I have removed some lines of the code, as they are not relevant (The ethernet shield connecting to NodeRed, etc),
The code in question is here:
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include <aREST.h>
#include <avr/wdt.h>
#include <FastLED.h>
#include <SoftwareSerial.h>
int door1RPWM = 22;
int door1LPWM = 23;
int door2RPWM = 24;
int door2LPWM = 25;
int door3RPWM = 26;
int door3LPWM = 27;
int door4RPWM = 28;
int door4LPWM = 29;
int drawer1 = 34;
int drawer2 = 35;
int drawer3 = 36;
int drawer4 = 37;
// aREST to NodeRed
int HTTP_PORT = 1880;
String HTTP_METHOD = "GET";
char HOST_NAME[] = "172.16.40.100";
String PATH_NAME = "/api";
String queryString = "";
// Create aREST instance
aREST rest = aREST();
void setup() {
pinMode(door1RPWM, OUTPUT);
pinMode(door1LPWM, OUTPUT);
pinMode(door2RPWM, OUTPUT);
pinMode(door2LPWM, OUTPUT);
pinMode(door3RPWM, OUTPUT);
pinMode(door3LPWM, OUTPUT);
pinMode(door4RPWM, OUTPUT);
pinMode(door4LPWM, OUTPUT);
pinMode(drawer1, OUTPUT);
pinMode(drawer2, OUTPUT);
pinMode(drawer3, OUTPUT);
pinMode(drawer4, OUTPUT);
digitalWrite(drawer1, HIGH);
digitalWrite(drawer2, HIGH);
digitalWrite(drawer3, HIGH);
digitalWrite(drawer4, HIGH);
}
void loop() {
//commands that will run over and over
}
void triggerDoor(String whichDoor, bool doorState) { //doorState false=close, true=open
for (int x = 0; x < 6; x++) {
if (whichDoor == x) {
if (whichDoor == 5) {
// trigger for all doors
for (int i = 0; i < 5; i++) {
if (doorState == false) {
analogWrite("door" + whichDoor + "RPWM", 255);
//analogWrite('door' + whichDoor + 'LPWM', 0);
if (doorState == false) {
NodeRedUpdate("?game=center&action=door" + whichDoor + "&command=false");
} else if (doorState == true) {
NodeRedUpdate("?game=center&action=door" + whichDoor + "&command=true");
}
#ifdef debug
Serial.print(F("Closing door: "));
Serial.println(whichDoor);
#endif
} else if (doorState == true) {
//analogWrite(rpwm, 0);
//analogWrite(lpwm, 255);
if (doorState == false) {
NodeRedUpdate("?game=center&action=door" + whichDoor + "&command=false");
} else if (doorState == true) {
NodeRedUpdate("?game=center&action=door" + whichDoor + "&command=true");
}
#ifdef debug
Serial.print(F("Opening door: "));
Serial.println(whichDoor);
#endif
}
}
}
}
}
}
int NodeRedUpdate(String query) {
if (client.connect(HOST_NAME, HTTP_PORT)) {
client.println(HTTP_METHOD + " " + PATH_NAME + query + " HTTP/1.1");
client.println("Host: " + String(HOST_NAME));
client.println(F("Connection: close"));
client.println();
while (client.connected()) {
if (client.available()) {
char c = client.read();
//Serial.print(c);
}
}
client.stop();
//Serial.println(F("disconnected"));
} else {
//Serial.println(F("connection failed"));
}
}
error: cannot convert 'StringSumHelper' to 'char*' for argument '1' to 'char* strcat(char*, const char*)'
analogWrite(strcat("door" + whichDoor + "RPWM"), 255);
^
exit status 1
cannot convert 'StringSumHelper' to 'char*' for argument '1' to 'char* strcat(char*, const char*)'