You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 line
830 B

  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <string.h>
  4. #include <wiringPi.h>
  5. #include <softPwm.h>
  6. #define RANGE 100
  7. #define NUM_LEDS 12
  8. int ledMap [NUM_LEDS] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13 } ;
  9. int values [NUM_LEDS] = { 0, 17, 32, 50, 67, 85, 100, 85, 67, 50, 32, 17 } ;
  10. int main ()
  11. {
  12. int i, j ;
  13. if (wiringPiSetup () == -1)
  14. {
  15. fprintf (stdout, "oops: %s\n", strerror (errno)) ;
  16. return 1 ;
  17. }
  18. for (i = 0 ; i < NUM_LEDS ; ++i)
  19. {
  20. softPwmCreate (ledMap [i], 0, RANGE) ;
  21. printf ("%3d, %3d, %3d\n", i, ledMap [i], values [i]) ;
  22. }
  23. for (;;)
  24. {
  25. for (i = 0 ; i < NUM_LEDS ; ++i)
  26. softPwmWrite (ledMap [i], values [i]) ;
  27. delay (50) ;
  28. i = values [0] ;
  29. for (j = 0 ; j < NUM_LEDS - 1 ; ++j)
  30. values [j] = values [j + 1] ;
  31. values [NUM_LEDS - 1] = i ;
  32. }
  33. }