using a checkbox

Support forum for MegunoLink
Post Reply
dogr127
Posts: 2
Joined: Wed Nov 22, 2017 10:02 am

Wed Nov 22, 2017 10:19 am

Hi,

I am trying to used a checkbox which is set to send a command like this. "!my_checkbox [my_checkbox.Checked]\r\n"

In my arduino code I have the following line in the setup.
SerialCommandHandler.AddVariable(F("my_checkbox"), checked);

My question is what data type I should use for the variable 'checked'.
I tried boolean, but it gave me a compiling error.

d.
philr
Posts: 300
Joined: Mon May 26, 2014 10:58 am

Wed Nov 22, 2017 10:40 am

Hi change your code to use this
[IPCheckBox1.Checked ? "1" : "0"]

That will send a 1 or 0 for true or false. I'm not sure if the addvariable supports Boolean but If not use an integer and do your logic on that.

Cheers
Phil
dogr127
Posts: 2
Joined: Wed Nov 22, 2017 10:02 am

Wed Nov 22, 2017 11:41 pm

Thanks Phil!

Now, it is working.

d.
Post Reply