arduino:basic_interaction
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:basic_interaction [2012/09/14 00:45] – mithat | arduino:basic_interaction [2012/09/14 01:06] – mithat | ||
---|---|---|---|
Line 14: | Line 14: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | The following examples will need switches with pullups or internal pullups turned on with | + | The following examples will need switches with external |
<code c> | <code c> | ||
Line 21: | Line 21: | ||
I suspect internal pullups is the better way to go but possibly harder to explain. | I suspect internal pullups is the better way to go but possibly harder to explain. | ||
+ | |||
+ | Alternately, | ||
</ | </ | ||
Line 43: | Line 45: | ||
// set LED state accordingly | // set LED state accordingly | ||
- | if (buttonState == HIGH) // if the button is pushed | + | if (buttonState == LOW) // if the button is pushed |
- | digitalWrite(ledPin, | + | digitalWrite(ledPin, |
- | else // otherwise | + | else |
- | digitalWrite(ledPin, | + | digitalWrite(ledPin, |
| | ||
// | // | ||
Line 72: | Line 74: | ||
void loop() { | void loop() { | ||
int buttonState = digitalRead(pushButtonPin); | int buttonState = digitalRead(pushButtonPin); | ||
- | digitalWrite(ledPin, | + | digitalWrite(ledPin, |
// | // | ||
} | } | ||
Line 94: | Line 96: | ||
void loop() { | void loop() { | ||
- | digitalWrite(ledPin, | + | digitalWrite(ledPin, |
// | // | ||
} | } | ||
</ | </ |
arduino/basic_interaction.txt · Last modified: 2012/09/14 01:19 by mithat