chiark / gitweb /
wiringPi Version 2 - First commit (of v2)
[wiringPi.git] / examples / blink8.c
similarity index 66%
rename from examples/test2.c
rename to examples/blink8.c
index 580591e98b09f409eadf62d3ee9be3ec6ef4e067..602d3c05965402d782f956f121d64bb962fb6c04 100644 (file)
@@ -1,6 +1,7 @@
 /*
- * 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 ;
 }