en:pfw:switchledwithbutton
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:pfw:switchledwithbutton [2025-06-22 00:00] – created mka | en:pfw:switchledwithbutton [2025-06-22 00:26] (current) – ↷ Links angepasst, weil Seiten im Wiki verschoben wurden mka | ||
---|---|---|---|
Line 21: | Line 21: | ||
Function: toggleLED ( -- ) \ Demo | Function: toggleLED ( -- ) \ Demo | ||
LOOP: | LOOP: | ||
- | IF: button was pressed, toggle LED | + | |
- | | + | halt testing button |
- | IF: button has been released stabel H | + | IF: button has been released stabel H |
- | | + | enable testing again |
- | ENDLOOP if any key is pressed | + | ENDLOOP if any key is pressed |
</ | </ | ||
Line 165: | Line 165: | ||
You can use it as follows: | You can use it as follows: | ||
+ | < | ||
+ | toggleled <ret> | ||
+ | </ | ||
- | | ||
- | |||
==== Glossary ==== | ==== Glossary ==== | ||
- | clavis? and tasto? are different methods for querying the button. | + | '' |
- | Clavis? checks whether there has been a falling edge on the pin. The port pin remembers this in its interrupt flag bit, requiring no additional wiring on the MCU. | + | '' |
- | Tasto?, on the other hand, monitors the logic level on the port pin several times in succession. Only when all queries have returned an H level is it assumed that the bouncing is over, i.e., the button has been released. | + | '' |
With these two routines, the state of the LED can be toggled back and forth. | With these two routines, the state of the LED can be toggled back and forth. | ||
- | Only when the button has been safely released does clavis? fire on the next keypress. | + | Only when the button has been safely released does '' |
- | The " | + | The " |
==== Background information ==== | ==== Background information ==== | ||
- | See clavis? and tasto? for more background information. | + | See [[en: |
- | Here, clavis? has been configured to immediately clear its interrupt flag after the query. This isn't really necessary, since it can only be queried again after tasto? allows it and has cleared the flag. | + | Here, '' |
==== Possible Pitfalls ==== | ==== Possible Pitfalls ==== |
en/pfw/switchledwithbutton.1750543250.txt.gz · Last modified: 2025-06-22 00:00 by mka