aaaaaaaa吧 关注:938贴子:2,120
  • 3回复贴,共1
#include <stdio.h>
#include <stdlib.h>
#include <wiringPi.h>
#define BUTTONPIN 1
int counter =0;
void myinterrupt(){
counter++;
printf("counter = %d\n",counter);
}
int main(){
wiringPiSetup();
pinMode(BUTTONPIN,INPUT);
wiringPiISR(BUTTONPIN,INT_EDGE_RISING,&myinterrupt);
printf("counter = %d\n",counter);
while(1){}
return 0;
}


1楼2020-12-13 20:29回复
    //
    //PWM控制LED
    //
    #include <iostream>
    #include <wiringPi.h>
    #include <softPwm.h>
    using namespace std;
    const int led = 1;// GPIO1
    int main (void) {
    if ( wiringPiSetup ()==-1)//设定WiringPi
    return 0;
    softPwmCreate( led, 0,100 );//设定软醋 PWM值介於0~100之間
    while ( 1 ){
    int val;
    for ( val = 0 ; val <= 100 ; val++){//从暗樊亮
    softPwmWrite( led, val );
    delay( 20 );
    }
    for ( val = 100 ; val >= 0 ; val--){//徙亮燮暗
    softPwmWrite( led, val );
    delay( 20 );
    }
    }
    return 1;
    }


    2楼2020-12-13 20:29
    回复
      a


      IP属地:贵州来自Android客户端3楼2023-11-20 21:13
      回复
        a


        IP属地:贵州来自Android客户端4楼2023-11-20 21:17
        回复