User Manual
73
Code Explanation
static volatile int globalCounter = 0 ; // a static integer variable to store the pulse
count
void exInt0_ISR(void) { //GPIO0 interrupt service routine
++globalCounter;
}
wiringPiISR(Pin0, INT_EDGE_FALLING, &exInt0_ISR); // set an interrupt here and the
signal is falling edge for Pin 0. When the interrupt happens, execute the function
exInt0_ISR(), and the pulse count will add 1.
while(1){ // if no interrupt happens, the pulse count will stay and just print it.
printf("Current pulse number is : %d\n", globalCounter);
}
For Python users:
Step 2: Get into the folder of the code.
cd /home/pi/SunFounder_Super_Kit_V3.0_for_Raspberry_Pi/Python
Step 3: Run
sudo python 09_ne555.py
Now you can see the number of square waves printed. Spin the potentiometer and the value
will decrease or increase.
SunFounder