arduino:arduino_crash_course:digital_input
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
arduino:arduino_crash_course:digital_input [2012/11/06 00:42] – mithat | arduino:arduino_crash_course:digital_input [2017/11/06 02:38] – [Digital Input] mithat | ||
---|---|---|---|
Line 11: | Line 11: | ||
Typically, digital input signals are designed so that when HIGH they have a value equal to the supply voltage and when LOW they are equal to 0 volts. | Typically, digital input signals are designed so that when HIGH they have a value equal to the supply voltage and when LOW they are equal to 0 volts. | ||
- | We've already seen an example of Arduino digital inputs in the [[arduino: | + | We've already seen an example of Arduino digital inputs in the [[arduino: |
+ | |||
+ | We have also added the '' | ||
<file c LightSwitchPullup2a.ino> | <file c LightSwitchPullup2a.ino> | ||
Line 101: | Line 103: | ||
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 117: | ||
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