Arduino HIGH LOW

Void Star picture Void Star · Sep 15, 2012 · Viewed 48.8k times · Source

I have an Arduino and I am wondering exactly what HIGH and LOW mean as far as actual values go... Are they signed ints? Unsigned ints? Unsigned chars??? What are their values? I am guessing that HIGH and LOW are probably unsigned ints with all of the bits set to 1 and 0 respectively, but I'm not sure. I would like to be able to do bitwise operations using HIGH and LOW or pass values other than HIGH or LOW to digitalWrite. Also, how would I cast an integer to HIGH or LOW so I could do this?

Answer

codeling picture codeling · Sep 15, 2012

Have a look at hardware/arduino/cores/arduino/Arduino.h (at least in Arduino 1.0.1 software), lines 18 and 19:

 #define HIGH 0x1
 #define LOW  0x0

Meaning, these defines being hexadecimal integer values, you can do whatever bitwise operations you want with them - how much sense that will make, however, is not really clear to me at the moment. Also bear in mind that these values might be subject to change at a later time - which would make bitwise operations on them even more unwise.