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.
 
 
 
 
 

70 lines
1.2 KiB

  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. char buf [80] ;
  14. if (wiringPiSetup () == -1)
  15. {
  16. fprintf (stdout, "oops: %s\n", strerror (errno)) ;
  17. return 1 ;
  18. }
  19. for (i = 0 ; i < NUM_LEDS ; ++i)
  20. {
  21. softPwmCreate (ledMap [i], 0, RANGE) ;
  22. printf ("%3d, %3d, %3d\n", i, ledMap [i], values [i]) ;
  23. }
  24. fgets (buf, 80, stdin) ;
  25. // Bring all up one by one:
  26. for (i = 0 ; i < NUM_LEDS ; ++i)
  27. for (j = 0 ; j <= 100 ; ++j)
  28. {
  29. softPwmWrite (ledMap [i], j) ;
  30. delay (10) ;
  31. }
  32. fgets (buf, 80, stdin) ;
  33. // Down fast
  34. for (i = 100 ; i > 0 ; --i)
  35. {
  36. for (j = 0 ; j < NUM_LEDS ; ++j)
  37. softPwmWrite (ledMap [j], i) ;
  38. delay (10) ;
  39. }
  40. fgets (buf, 80, stdin) ;
  41. for (;;)
  42. {
  43. for (i = 0 ; i < NUM_LEDS ; ++i)
  44. softPwmWrite (ledMap [i], values [i]) ;
  45. delay (50) ;
  46. i = values [0] ;
  47. for (j = 0 ; j < NUM_LEDS - 1 ; ++j)
  48. values [j] = values [j + 1] ;
  49. values [NUM_LEDS - 1] = i ;
  50. }
  51. }