Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PIN_DECREASE 1
- #define PIN_INCREASE 2
- int16_t counter = 0;
- int8_t old_state_pin_decrease = 0;
- int8_t old_state_pin_increase = 0;
- int8_t current_state_pin_decrease = 0;
- int8_t current_state_pin_increase = 0;
- void setup()
- {
- pinMode(PIN_DECREASE, INPUT);
- pinMode(PIN_INCREASE, INPUT);
- }
- void loop()
- {
- current_state_pin_decrease = digitalRead(PIN_DECREASE);
- if (current_state_pin_decrease != old_state_pin_decrease)
- {
- counter--;
- old_state_pin_decrease = current_state_pin_decrease;
- }
- current_state_pin_increase = digitalRead(PIN_INCREASE);
- if (current_state_pin_increase != old_state_pin_increase)
- {
- counter++;
- old_state_pin_increase = current_state_pin_increase;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement