arduino:arduino_crash_course:digital_input
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
arduino:arduino_crash_course:digital_input [2012/11/06 00:42] – mithat | arduino:arduino_crash_course:digital_input [2012/11/12 18:29] – [Software debouncing] mithat | ||
---|---|---|---|
Line 101: | Line 101: | ||
boolean lastButtonState = HIGH; // value of buttonState from previous loop iteration | boolean lastButtonState = HIGH; // value of buttonState from previous loop iteration | ||
boolean buttonState = HIGH; | boolean buttonState = HIGH; | ||
- | |||
- | /* boolean debounce(int pinNum, boolean lastState) { | ||
- | boolean nowState = digitalRead(pinNum); | ||
- | if (lastState != nowState) { | ||
- | delay(debounceTime); | ||
- | nowState = digitalRead(pinNum); | ||
- | } | ||
- | return nowState; | ||
- | } */ | ||
boolean debounce(int pinNum) { | boolean debounce(int pinNum) { | ||
Line 124: | Line 115: | ||
void loop() { | void loop() { | ||
- | // buttonState = debounce(pushButtonPin, | ||
buttonState = debounce(pushButtonPin); | buttonState = debounce(pushButtonPin); | ||
arduino/arduino_crash_course/digital_input.txt · Last modified: 2017/12/06 01:13 by mithat