We're no longer updating This wiki!!

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
en:c_16x2lcd_interrupt [2015/05/08 18:41]
john1117
en:c_16x2lcd_interrupt [2015/05/08 18:42] (current)
john1117
Line 1: Line 1:
 +====== Button Interrupt example ====== 
 +  gcc -o wiring_isr wiring_isr.c -lwiringPi -lpthread 
 +  ./​wiring_isr 
 +Push your SW1 on 16x2lcd board 
 +<file c wiring_isr.c>​ 
 +#include <​stdio.h> ​                                                              
 +#include <​wiringPi.h> ​                                                           
 +                                                                                 
 +int volatile btnCounter; ​                                                        
 +                                                                                 
 +void myInterrupt(void) ​                                                          
 +{                                                                                
 +        btnCounter++; ​                                                           
 +}                                                                                
 +                                                                                 
 +int main(void) ​                                                                  
 +{                                                                                
 +        if (wiringPiSetup() < 0) {                                               
 +                printf("​wiringPiSetup error.\n"​); ​                               
 +                return 1;                                                        
 +        }                                                                        
 +        if (wiringPiISR(5,​ INT_EDGE_FALLING,​ &​myInterrupt) < 0) {                
 +                printf("​wiringPiISR error.\n"​); ​                                 
 +                return 1;                                                        
 +        }                                                                        
 +                                                                                 
 +        while(1) {                                                               
 +                printf("​%d\n",​ btnCounter); ​                                     
 +                delay(1000); ​                                                    
 +        }                                                                        
 +                                                                                 
 +        return 0;                                                                
 +
 +</​file>​
en/c_16x2lcd_interrupt.txt · Last modified: 2015/05/08 18:42 by john1117
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0