Created
April 4, 2013 03:04
-
-
Save pdp7/5307371 to your computer and use it in GitHub Desktop.
PWM demo for the PiFace by Gordon of drogon.net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* pifacePwm.c: | |
* Simple test for the PiFace interface board. | |
*********************************************************************** | |
*/ | |
#include <wiringPi.h> | |
#include <softPwm.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#define START 2 | |
#define END 7 | |
int main (void) | |
{ | |
int i, j ; | |
printf ("Raspberry Pi PiFace + PWM test program\n") ; | |
if (wiringPiSetupPiFace () == -1) | |
exit (1) ; | |
for (i = START ; i <= END ; ++i) | |
softPwmCreate (i, 0, 100) ; | |
for (;;) | |
{ | |
for (i = 0 ; i <= 100 ; ++i) | |
{ | |
for (j = START ; j <= END ; ++j) | |
softPwmWrite (j, i) ; | |
delay (20) ; | |
} | |
for (i = 100 ; i >= 0 ; --i) | |
{ | |
for (j = START ; j <= END ; ++j) | |
softPwmWrite (j, i) ; | |
delay (20) ; | |
} | |
} | |
return 0 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment