I have a device that takes commands through the serial monitor.
I have set it to send the 'r' command continuously by setting computerdata[0] = 'r'
I want to send commands that are more than one letter like "status". but every combination and variable I tried does not work.
I also wanted to do
char* = "stringvariable";
computerdata[0] = stringvariabl;e //but this doesn't work either.
char computerdata[20];
void loop(){
computerdata[0] = 'r';
rtd();
}void ezoec(){
if (millis() - ecTimer >= 1000){ //start rtd timer
if (readec2 == 1){
computerdataec[0] = tolower(computerdataec[0]); //we make sure the first char in the string is lower case
if (computerdataec[0] == 'c' || computerdataec[0] == 'r')timeec = 1000; //if a command has been sent to calibrate or take a reading we wait 2000ms so that the circuit has enough time to take the reading.
else timeec = 300;readec = 1;
readec2 = 0;
ecTimer2 = millis();
}
}
if (millis() - ecTimer2 >= timeec){
if (readec == 1){// Serial.println("requestion ec data"); //print the data for ddebug
Wire.requestFrom(addressec, 48, 1); //call the circuit and request 48 bytes (this is more than we need)
codeec=Wire.read(); //the first byte is the response code, we read this separately.
while(Wire.available()){ //are there bytes to receive.
in_charec = Wire.read(); //receive a byte.
ec_data[iec]= in_charec; //load this byte into our array.
iec+=1; //incur the counter for the array element.
if(in_charec==0){ //if we see that we have been sent a null command.
iec=0; //reset the counter i to 0.
Wire.endTransmission(); //end the I2C data transmission.
break; //exit the while loop.
}
}
// Serial.println(ec_data); //print the data.
Wire.endTransmission(); //end the I2C data transmission.
readec2 = 1;
readec = 0;
ecTimer = millis(); // reset timer
ecTimer2 = millis();
}
}
}