Home Security System with Arm Function Not working

I took the liberty to "slightly" reformat your code (see how to embed code blocks) and removed some superfluous blank lines. You can make your code much more readable by adopting a consistent indentation scheme than with spreading out your code over more lines than necessary by sprinkling it with blank lines.

About the use of Particle.variable()

Actually sprinkling Particle.variable() inside loop() is not only less efficient, it's actually wrong and will actually break the variables. Additionally (currently) any change to the cloud "interface" (set of Particle.variable(), Particle.function() & Particle.subscribe() statements to define the interface) some time after Particle.connect() won't have any effect on the cloud side as the changes are only communicated to the cloud within a few seconds after the connection was established.
BTW, the three parameter call is deprecated. Look at the docs to see how it's done nowadays.

For that reason some C/C++ devs adopt a slightly confusing but protecting syntax with equality checks.

// instead of 
if (someVar == 10) 
// they always write it the other way round
if (10 == someVar)
// and that way a missing = in
if (10 = someVar)
// would fail at compile time with a clear error message.

(obviously only protects you when using literals or const variables on the left side)

BTW, statements like if (someVar = 10) would produce a compiler warning, but when you have no errors you will never get to see them. In such a case, you can try to add a deliberate syntax error (e.g. a stray { after your last }). This way you will be presented with an error message and in Web IDE you can then hit SHOW RAW to actually see the compile output including the warnings.

4 Likes