Changing int values based on incoming serial characters. Phone app via bluetooth

I am currently working on a project to control a portable heat pump with a phone app via blue tooth.

I am currently working on a method to switch from heating to cooling mode by sending a c or h to the serial port, reading it and then adjust the integer value of (mode) based on whether a c or h is received over the serial bus.

I can't seem to get mode to change its value. it always returns a value of 0 to the serial bus.

Any help would be greatly appreciated!

Code below.

int mode;
char (m);

void setup() {

void loop() {

//Check for incoming serial commands from bluetooth, a value of h for heating and c for cooling.
// If h, set mode equal to 1.
// If c, set mode equal to -1

if (Serial.available() > 0) //If something is on the serial it.
char (m) =; //Assign the character m to the value on the incoming serial line.

Serial.println (m); //Print the the value (m).

if (char (m)="h") //If the the incoming serial value is "h".
int (mode) = 1; //Set the value of (mode) eqaul to 1.
else //Otherwise
int (mode) = -1; //Set the value of (mode) equal to -1.
Serial.println (mode); //Print the value of (mode)
delay (1000);

        if (char (m)="h")

2 things: should be "==" not "=", but more importantly "char m" defines a new variable "m" with the condition test.

same here, a new variable "m" is definde within the braces "{}" of the above if

            int (mode) = 1;

and again within the scope of the else

        int (mode) = -1;

"m" is defined at the top of the file. that is the only time is should be preceded with "int"

int mode;

Shouldn’t it be compared to ‘h’ the character not “h” the literal string of length 1?


You were both right

Working perfectly now.

Thank you both very much!!!!