What does this code do?

Post Reply
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

What does this code do?

Post by cosmith71 »

Too much punctuation! Can somebody 'splain?

Code: Select all

        WhiteChannel=millis()%2000<1000?0:100;
Thanks,

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: What does this code do?

Post by lnevo »

StartTIme+Offset%Repeat<RunTime is the basis for most of the timechecks. You arent using the offset above but if you wanted thats how it works.

The ?0:100 is like an if else so if the condiction prior is true then 0 else 100
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: What does this code do?

Post by cosmith71 »

lnevo wrote:StartTIme+Offset%Repeat<RunTime is the basis for most of the timechecks. You arent using the offset above but if you wanted thats how it works.

The ?0:100 is like an if else so if the condiction prior is true then 0 else 100
You hurt my brain a little just then.

So, does this mean if millis mod 2000 is less than 1000 then WhiteChannel=0 else WhiteChannel=100?

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: What does this code do?

Post by lnevo »

Why yes, yes it does :)
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: What does this code do?

Post by cosmith71 »

Thanks! :D

--Colin
Post Reply