lab2-5-2.c
361 Bytes
#include <wiringPi.h>
#include <softPwm.h>
#define LedPin 22
int main(void){
if (wiringPiSetupGpio() == -1)
return 1;
pinMode(LedPin, OUTPUT);
softPwmCreate(LedPin, 0, 128);
int i;
while(1){
for(i=0;i<129;i+=8){
softPwmWrite(LedPin, i);
delay(100);
}
for(i=128;i>-1;i-=8){
softPwmWrite(LedPin,i);
delay(100);
}
}
return 0;
}