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?
If a pull-down resistor is used, the input pin will be LOW when the switch is open and HIGH when the switch is closed. If a pull-up resistor is used, the input pin will be HIGH when the switch is open and LOW when the switch is closed.
So HIGH is exactly the same as 1 . And LOW exactly the same as 0 .
The pin states can be checked by switching to the digital input mode programmatically. The input is “LOW” at 0V or “HIGH” at 5V. The program reads “0” as LOW and “1” as HIGH.
The terms "set low" and "set high", applied to an output pin, mean to drive the output voltage to VSS or VDD, respectively, regardless of whether the pin's value will be interpreted as an active-low signal. The terms "release" or "float the pin" means to set an output to high-impedance mode.
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.
To add my two cents to codeling's answer:
Lines 18--25 of Arduino.h
(1.0) are:
#define HIGH 0x1 #define LOW 0x0 #define INPUT 0x0 #define OUTPUT 0x1 #define true 0x1 #define false 0x0
Therefore, HIGH <==> OUTPUT <==> true <==> 0x1
and LOW <==> INPUT <==> false <==> 0x0
. Then, HIGH <==> !LOW
and LOW <==> !HIGH
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With