Page 1 of 1

In between decision!

Posted: Fri Apr 20, 2018 9:21 pm
by jgu1
Hi!

Help needed. I am making a project with a GPS module. I am using the time (clock). I want to set an output on or off in between some hours.

Is it possible in an if decision to make a command "if hour is between 3 and 8 then yes or no. So what I mean if a variable is in between two value.

Hope you understand-

Yhanks in advance

Br jorgen

Re: In between decision!

Posted: Fri Apr 20, 2018 10:22 pm
by mnf

Code: Select all

(hour >= 3) and (hour <= 8)
Or use > and < if it's not inclusive..

Martin

Re: In between decision!

Posted: Sat Apr 21, 2018 6:36 am
by jgu1
Hi Martin!

Just what I need. Thank you very much for help. :D

Br. Jorgen

Re: In between decision!

Posted: Sat Apr 21, 2018 7:58 am
by mnf
Lookup "Boolean logical operators" in C. The standard operators for examples && || work, and Flowcode helpfully converts 'and' and 'or' into the correct equivalent....

Note also that although parentheses () are not essential - care is needed as sometimes operator precedence can play tricks on you.. Brackets will keep things clearer and stop any surprises so I would recommend their use when combining terms.

Martin