BINARY HIGH & LOW
Posted: 10 Jul 2017 03:28
Please refer to the code snippet below that come from the Sensor wall based Switch example.
I can see where the HIGH comes from, in this case byte lastValue1=HIGH) but later in the code there is reference to LOW, as it hasn't been defined is it assumed that it is NOT HIGH (!HIGH) or has it been an omission form the the code?
If so can the line of code be written as !HIGH ?
Code: Select all
byte lastValue1 = HIGH;
byte lastValue2 = HIGH;
// the setup routine runs once when you press reset:
void setup() {
pinMode(BTN_PIN1, INPUT_PULLUP);
pinMode(BTN_PIN2, INPUT_PULLUP);
}
// the loop routine runs over and over again forever:
void loop() {
byte currentValue1 = digitalRead(BTN_PIN1);
byte currentValue2 = digitalRead(BTN_PIN2);
// Button Down
if (currentValue1 != lastValue1) { // if state changes
lastValue1 = currentValue1; // save new state
if (lastValue1 == LOW) {
zunoSendToGroupSetValueCommand(CONTROL_GROUP, SWITCH_OFF); // if button pressed - send switch OFF command
}
If so can the line of code be written as !HIGH ?