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 revision | ||
arduino:arduino_crash_course:basic_interaction [2015/02/13 22:27] – mithat | arduino:arduino_crash_course:basic_interaction [2017/12/06 01:05] (current) – mithat | ||
---|---|---|---|
Line 9: | Line 9: | ||
In an interrupt scheme, the microcontroller does essentially nothing in its main loop, but it is directed to do something specific when an input source jostles it into action. | In an interrupt scheme, the microcontroller does essentially nothing in its main loop, but it is directed to do something specific when an input source jostles it into action. | ||
- | Of the two, polling is probably easier to get started with. You can use both techniques | + | Of the two, polling is probably easier to get started with. We won't learn how to work with interrupts in this section, but it's good to know that you can use both techniques |
- | Following is a simple example of using polling. | + | ===== Polling example: switch-controlled LED ===== |
- | + | ||
- | ===== Switch-controlled LED ===== | + | |
The following examples use polling to determine the state of a switch. If the switch is pressed, the Arduino will turn an LED on. If it is not pressed, it will turn the LED off. | The following examples use polling to determine the state of a switch. If the switch is pressed, the Arduino will turn an LED on. If it is not pressed, it will turn the LED off. | ||
Line 72: | Line 70: | ||
buttonState = digitalRead(pushButtonPin); | buttonState = digitalRead(pushButtonPin); | ||
digitalWrite(ledPin, | digitalWrite(ledPin, | ||
- | // | + | // |
} | } | ||
</ | </ | ||
Line 96: | Line 94: | ||
void loop() { | void loop() { | ||
digitalWrite(ledPin, | digitalWrite(ledPin, | ||
- | // | + | // |
} | } | ||
</ | </ |
arduino/arduino_crash_course/basic_interaction.1423866442.txt.gz · Last modified: 2015/02/13 22:27 by mithat