Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arduino HIGH LOW

Tags:

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?

like image 902
Void Star Avatar asked Sep 14 '12 22:09

Void Star


People also ask

What does high and low mean in Arduino?

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.

Is 1 high or low Arduino?

So HIGH is exactly the same as 1 . And LOW exactly the same as 0 .

How do you check if a pin is high or low Arduino?

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.

What does it mean to set a pin high or low?

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.


2 Answers

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.

like image 163
codeling Avatar answered Oct 22 '22 09:10

codeling


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...

like image 27
Alvaro Avatar answered Oct 22 '22 10:10

Alvaro