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.
 
 
 
 
 

42 regels
587 B

  1. /*
  2. * test2.c:
  3. * Simple test program to test the wiringPi functions
  4. * PWM test
  5. */
  6. #include <wiringPi.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <stdint.h>
  10. int main (void)
  11. {
  12. int bright ;
  13. printf ("Raspberry Pi wiringPi PWM test program\n") ;
  14. if (wiringPiSetup () == -1)
  15. exit (1) ;
  16. pinMode (1, PWM_OUTPUT) ;
  17. for (;;)
  18. {
  19. for (bright = 0 ; bright < 1024 ; ++bright)
  20. {
  21. pwmWrite (1, bright) ;
  22. delay (1) ;
  23. }
  24. for (bright = 1023 ; bright >= 0 ; --bright)
  25. {
  26. pwmWrite (1, bright) ;
  27. delay (1) ;
  28. }
  29. }
  30. return 0 ;
  31. }