arduino:arduino_crash_course:basic_interaction
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
arduino:arduino_crash_course:basic_interaction [2012/11/05 22:13] – mithat | arduino:arduino_crash_course:basic_interaction [2012/11/05 22:16] – [Using internal pullups] mithat | ||
---|---|---|---|
Line 132: | Line 132: | ||
// set LED state accordingly | // set LED state accordingly | ||
- | // note the inverted | + | // becasue we are using pullup resistors, |
+ | // in other words, pressed produces LOW, un-pressed produces HIGH. | ||
if (buttonState == LOW) // if the button is pushed | if (buttonState == LOW) // if the button is pushed | ||
digitalWrite(ledPin, | digitalWrite(ledPin, | ||
Line 158: | Line 159: | ||
void loop() { | void loop() { | ||
- | buttonState = !digitalRead(pushButtonPin); | + | buttonState = digitalRead(pushButtonPin); |
- | digitalWrite(ledPin, | + | |
+ | // set LED state accordingly | ||
+ | // becasue we are using pullup resistors, the logic is inverted; | ||
+ | // in other words, pressed produces LOW, un-pressed produces HIGH. | ||
+ | digitalWrite(ledPin, | ||
} | } | ||
</ | </ |
arduino/arduino_crash_course/basic_interaction.txt · Last modified: 2017/12/06 01:05 by mithat