We're no longer updating This wiki!!

Button Interrupt example

gcc -o wiring_isr wiring_isr.c -lwiringPi -lpthread
./wiring_isr

Push your SW1 on 16x2lcd board

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;                                                               
}
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