2 * Show quadrature states of two Hall effect sensors.
4 * Copyright (C) 2018 Antonio Ospite <ao2@ao2.it>
5 * SPDX-License-Identitier: WTFPL
8 #define HALL_CHANNEL_A 2
9 #define HALL_CHANNEL_B 3
15 int old_hall_state_A = -1;
16 int old_hall_state_B = -1;
20 pinMode(HALL_CHANNEL_A, INPUT);
21 pinMode(HALL_CHANNEL_B, INPUT);
22 pinMode(LED_PIN, OUTPUT);
28 hall_state_A = digitalRead(HALL_CHANNEL_A);
29 hall_state_B = digitalRead(HALL_CHANNEL_B);
31 if (hall_state_A != old_hall_state_A ||
32 hall_state_B != old_hall_state_B)
34 digitalWrite(LED_PIN, hall_state_A);
36 old_hall_state_A = hall_state_A;
37 old_hall_state_B = hall_state_B;
39 Serial.print(hall_state_A);
41 Serial.print(hall_state_B);