Members | Sign In
MOVI User Community Forum > MOVI Question & Answers
avatar

Multiple "res==" values in one if statement

posted Jun 08, 2016 16:10:12 by BrandonMoore
For the project I am working on, I want to be able to turn on certain outputs individually, but I also would like to set a master switch for a few toggles as well. Could something like this work with MOVI?

if (res==3 or res==1)
//commands here

if (res==4 or res==2)
//commands here

where res==1 is MASTER SWITCH ON
res==2 is MASTER SWITCH OFF
res==3 is COMMAND ONE ON
res==4 is COMMAND ONE OFF

Using this method, my idea is that it would allow me to say "command one on" OR "master switch on" and either way it would execute the commands within that if statement. Is this supported on MOVI and can I make it work? If not, what would be a recommended way to approach this? Thank you.
page   1
3 replies
avatar
Pritcharduino said Jun 08, 2016 18:48:06
Hi!

I see no reason why that wouldn't work. Did you try the following?

if (res==1 || res==3){
//commands here
}

|| is the Boolean 'OR' operator.

MOVI just recognizes the words, and your Arduino board does the rest. I used this method for a conversation engine I'm developing, and it works fine.

Let me know if this works for you!
Building human-scale anthropomorphic robots.
avatar
BrandonMoore said Jun 08, 2016 19:07:34
That did work, but it turns out the reason "or" wasnt working is because my sentences werent being trained. I am having to manually train them via the serial monitor. Any idea what the problem here is?
avatar
GeraldFriedland said Jun 09, 2016 00:48:10
See my other reply on memory and serial connection.
Login below to reply: