Skip to content

Instantly share code, notes, and snippets.

@pdp7
Created April 4, 2013 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdp7/5307371 to your computer and use it in GitHub Desktop.
Save pdp7/5307371 to your computer and use it in GitHub Desktop.
PWM demo for the PiFace by Gordon of drogon.net
/*
* 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