Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

okLed.c 2.1 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * okLed.c:
  3. * Make the OK LED on the Pi Pulsate...
  4. *
  5. * Originally posted to the Raspberry Pi forums:
  6. * http://www.raspberrypi.org/phpBB3/viewtopic.php?p=162581#p162581
  7. *
  8. * Compile this and store it somewhere, then kick it off at boot time
  9. * e.g. by putting it in /etc/rc.local and running it in the
  10. * background &
  11. *
  12. * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
  13. ***********************************************************************
  14. * This file is part of wiringPi:
  15. * https://projects.drogon.net/raspberry-pi/wiringpi/
  16. *
  17. * wiringPi is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Lesser General Public License as published by
  19. * the Free Software Foundation, either version 3 of the License, or
  20. * (at your option) any later version.
  21. *
  22. * wiringPi is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Lesser General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Lesser General Public License
  28. * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
  29. ***********************************************************************
  30. */
  31. #include <stdio.h>
  32. #include <errno.h>
  33. #include <string.h>
  34. #include <fcntl.h>
  35. #include <unistd.h>
  36. #include <math.h>
  37. #include <wiringPi.h>
  38. #include <softPwm.h>
  39. // The OK/Act LED is connected to BCM_GPIO pin 16
  40. #define OK_LED 16
  41. int main ()
  42. {
  43. int fd, i ;
  44. wiringPiSetupGpio () ;
  45. // Change the trigger on the OK/Act LED to "none"
  46. if ((fd = open ("/sys/class/leds/led0/trigger", O_RDWR)) < 0)
  47. {
  48. fprintf (stderr, "Unable to change LED trigger: %s\n", strerror (errno)) ;
  49. return 1 ;
  50. }
  51. write (fd, "none\n", 5) ;
  52. close (fd) ;
  53. softPwmCreate (OK_LED, 0, 100) ;
  54. for (;;)
  55. {
  56. for (i = 0 ; i <= 100 ; ++i)
  57. {
  58. softPwmWrite (OK_LED, i) ;
  59. delay (10) ;
  60. }
  61. delay (50) ;
  62. for (i = 100 ; i >= 0 ; --i)
  63. {
  64. softPwmWrite (OK_LED, i) ;
  65. delay (10) ;
  66. }
  67. delay (10) ;
  68. }
  69. return 0 ;
  70. }