Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1.  
  2. #include <led.h>
  3. #include <button.h>
  4.  
  5. void main(void) {
  6.    
  7.     int8_t counter = 0;
  8.    
  9.     int8_t old_state = sb_button_getState(BUTTON0);
  10.    
  11.    
  12.     while(1) {
  13.        
  14.         int new_state = sb_button_getState(BUTTON0);
  15.        
  16.        
  17.         if (old_state != new_state){
  18.            
  19.             counter++;
  20.         }
  21.        
  22.        
  23.         old_state = new_state;
  24.        
  25.         if (counter==2){
  26.            
  27.             sb_led_on(GREEN1);                                     
  28.             for( volatile uint16_t a = 0; a < 25000 ; a++){                    
  29.             }
  30.            
  31.             sb_led_off (GREEN1);                               
  32.             for( volatile uint16_t a = 0; a < 25000 ; a++){
  33.             }
  34.            
  35.             counter = 0;
  36.         }
  37.    
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement