General area when it fits no where else

Moderator: Mmiscool

User avatar
By Ecoli-557
#53396 OK you 8266 Basic Gurus, this noob is fuzzy on how I use decimal, Hex, and binary in a variable.
I am trying to do something really simple but I don't have any success.
If I wanted to see if a variable equals a hex value, how do you do it?
Want to see if pressed which is a var equals hex FF;
- none of these work:
if pressed <> HEX (FF) then print something
if pressed <> HEX ((FF)) then print something
if pressed <> 0xFF then print something
likewise, how do you set a vars value? Say I wanted to equate somevar equal to a hex value of A5?
somevar = 0xA5 doesn't work, somevar = HEX(A5) gives me 7FFFFFFFF
Then, how do you equate a variable to a binary number?
Say I wanted to equate or test a variable to 01010101?


Basically I want to equate any numeric variable to a decimal, hex, or binary value, compare a variable against any of these three.
Apologies if this is listed somewhere but I cannot find it in the docs or by perusing other work on this forum.
This is basic and should be easy??
User avatar
By Ecoli-557
#53407 Thanks joeygbsn for the reply.
I think I have that part down, what I don't know how to do correctly is equate a variable and then compare it against a value.
Pseudo code below:
SomeVar = hex A5
If SomVar <> hexA7 then print something
I tend to work in hex a bit due to my sensor work desires so getting the hex stuff is central to me getting this understood.
How do you equate a var to a hex value, then compare that var against a different hex value?