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
oak:tutorials:button [2016/03/20 05:11]
djflix Added example of interrupts
oak:tutorials:button [2016/03/20 05:13]
djflix
Line 42: Line 42:
  
 void good_handleButtonPress() { void good_handleButtonPress() {
-  ​event_has_happened = true; //set a bool to true so we can handle it in loop()+  //set a bool to true so we can handle it in loop() 
 +  event_has_happened = true; 
 } }
  
 void bad_handleButtonPress() { void bad_handleButtonPress() {
-  ​delay(500); ​// wait user to release button +  // wait user to release button 
-  ​call_another_slow_function(); //Handle the button press now so we won't forget it happened!+  ​delay(500);  
 +  ​//Handle the button press now so we won't forget it happened! 
 +  call_another_slow_function(); ​
 } }
 </​code>​ </​code>​
Line 59: Line 62:
  
 **2. LED** **2. LED**
-After adding the resistors, you can add the LED. When connecting the LED, double-check the polarity. The shorter leg is the cathode (-) and the longer leg is the anode (+). Connect the **cathode** to the top (10K) resistor, and connect the **anode** to P2 of the Oak using a wire (the blue wire in the example).+After adding the resistors, you can add the LED. When connecting the LED, double-check the polarity. The shorter leg is the cathode (-) and the longer leg is the anode (+). Connect the **cathode** to the top (150 Ohm) resistor, and connect the **anode** to P2 of the Oak using a wire (the blue wire in the example).
  
 **3. Button** **3. Button**
oak/tutorials/button.txt · Last modified: 2016/03/20 05:13 by djflix