HIGH and LOW equivalent to 1 and 0? Also, pulldown resistors required?

Hello All

Having set a pin to OUTPUT using pinMode, is a digitalWrite(myPin,HIGH) equivalent to digitalWrite(myPin,1) and similarly digitalWrite(myPin,LOW) equivalent to digitalWrite(myPin,0)?

Also, if I am setting a pin to output I guess I do not need to add pullup or pulldown resistors?

Cheers

AgeingHippy:
Hello All

Having set a pin to OUTPUT using pinMode, is a digitalWrite(myPin,HIGH) equivalent to digitalWrite(myPin,1) and similarly digitalWrite(myPin,LOW) equivalent to digitalWrite(myPin,0)?

Yes

Also, if I am setting a pin to output I guess I do not need to add pullup or pulldown resistors?

In most cases that is true. Sometimes there can be exceptions where one has wired digital output pins to external components or modules that are powered from voltage sources other then the arduino board. In that case one should consider the impact of what happens to the external components or modules if the arduino board is powered off (or held in reset mode) but the external component or modules still have power from their external voltage source on. In some cases an external pull-up or pull-down on the signal line powered by the external voltage source is required for safety reasons, such as making sure a motor doesn't run, etc when the arduino only is powered off.

Lefty

From wiring.h

#define HIGH 0x1
#define LOW  0x0

Great.

Thanks Guys

Since you are asking about HIGH and LOW. Keep in mind that when using pull-ups the default state is HIGH while the activated state is LOW. (This tends to be opposite of what people initially expect.)

So if you have a button attached, unpressed the value is HIGH (1) while pressed the value is LOW (0).