/*
- * test2.c:
- * This tests the hardware PWM channel.
+ * blink8.c:
+ * Simple sequence over the first 8 GPIO pins - LEDs
+ * Aimed at the Gertboard, but it's fairly generic.
*
* Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
***********************************************************************
***********************************************************************
*/
-#include <wiringPi.h>
-
#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
+#include <wiringPi.h>
int main (void)
{
- int bright ;
+ int i, led ;
- printf ("Raspberry Pi wiringPi PWM test program\n") ;
+ printf ("Raspberry Pi - 8-LED Sequencer\n") ;
+ printf ("==============================\n") ;
+ printf ("\n") ;
+ printf ("Connect LEDs to the first 8 GPIO pins and watch ...\n") ;
- if (wiringPiSetup () == -1)
- exit (1) ;
+ wiringPiSetup () ;
- pinMode (1, PWM_OUTPUT) ;
+ for (i = 0 ; i < 8 ; ++i)
+ pinMode (i, OUTPUT) ;
for (;;)
{
- for (bright = 0 ; bright < 1024 ; ++bright)
+ for (led = 0 ; led < 8 ; ++led)
{
- pwmWrite (1, bright) ;
- delay (1) ;
+ digitalWrite (led, 1) ;
+ delay (100) ;
}
- for (bright = 1023 ; bright >= 0 ; --bright)
+ for (led = 0 ; led < 8 ; ++led)
{
- pwmWrite (1, bright) ;
- delay (1) ;
+ digitalWrite (led, 0) ;
+ delay (100) ;
}
}
-
- return 0 ;
}