Please HELP

Hi Guis
I'm new to Arduino .Could you please help me with the following code. What I'd like to try is
building a cooling/heating thermostat with fan speed control, I think I think I manage to solve almost
everything, but the fan regulators. I'm using Arduino UNO, LCD Nokia5110. 3 buttons for accessing
menu. On submenu >Fan Speed I'm trying to add 3 submenus for LO, MID & HI speed, or I can control
3-pins on Arduino.
Thanks in advance with your help.
Nik

sketch_mar04b.ino (10.1 KB)

nik4o:
I manage to solve almost
everything, but the fan regulators.....I'm trying to add 3 submenus for LO, MID & HI speed, or I can control
3-pins on Arduino.

Looking at your code tells me you have have no problem with the off-board fan regulators, you're just asking help in aspects of menu building only. (Correct me if I'm mistaken.) I bring that out for other readers to look in the right direction helping you.

In lines 288 and following, you're using the assignment operator "=" where you want the comparison operator "==". Change if (fanSpeedControl = "xxx") {
to if (fanSpeedControl == "xxx") {

Does that help?

Hi kenneth558
Yes I have no problem with hardware part, I'm having big problem with menu building only.
Thanks I'll try it now and I'll post again.

Hi kenneth558
Unfortunately this didn't solve my problem I must missing something somewhere.
Thanks for your help.
Nick

One more thing - that is not the way to compare strings in c. You could use strcmp() instead:

if( strcmp( fanSpeedControl, "xxx" ) ) {

You could use strcmp() instead

Keep in mind that true does NOT mean that the strings match.

This is a perfect example of why C# and other newer languages do NOT allow an if statement to not include a comparison operator unless the condition is a boolean or explicitly evaluates to a boolean.

The statement you showed implies that the body will be executed if the strings match. That is not the case. The body will be executed if the strings do not match, because strcmp() returns 0 when the strings match, which is equivalent to false, and returns non-zero when they do not match.

PaulS:
Keep in mind that true does NOT mean that the strings match.

This is a perfect example of why C# and other newer languages do NOT allow an if statement to not include a comparison operator unless the condition is a boolean or explicitly evaluates to a boolean.

The statement you showed implies that the body will be executed if the strings match. That is not the case. The body will be executed if the strings do not match, because strcmp() returns 0 when the strings match, which is equivalent to false, and returns non-zero when they do not match.

Thank you. I looked back at my code and found I've been using strstr() instead. strstr() does work: if( strstr ( char*, const char*) ) when finding one string anywhere inside the other, leading to my mixup.