User Tools

Site Tools


oak:tutorials:button

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
oak:tutorials:button [2016/03/20 05:00]
djflix Fixed the non-interrupt example
oak:tutorials:button [2016/03/20 05:12]
djflix
Line 36: Line 36:
   * HIGH (pin is high)   * HIGH (pin is high)
  
-It's important to note that an Interrupt actually interrupts what you'​re ​doing! ​So keep your interrupt ​handlers as simple as possible. Otherwise they might interfere with other time-sensitive operations.+In interrupt will interrupt anything the microcontroller is doing (even if it is in the middle of a function!) but will return after executing the interrupt ​handlerSee some example of a good and a bad handleButtonPress() interrupt handler: 
 + 
 +<​code>​ 
 +bool event_has_happened = false; 
 + 
 +void good_handleButtonPress() { 
 +  //set a bool to true so we can handle it in loop() 
 +  event_has_happened = true;  
 +
 + 
 +void bad_handleButtonPress() { 
 +  // wait user to release button 
 +  delay(500);  
 +  //Handle the button press now so we won't forget it happened! 
 +  call_another_slow_function();​  
 +
 +</​code>​ 
  
 =====Circuit:​===== =====Circuit:​=====
oak/tutorials/button.txt · Last modified: 2016/03/20 05:13 by djflix