Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

README.md 5.6 KiB

8 meses atrás
8 meses atrás
8 meses atrás
8 meses atrás
8 meses atrás
8 meses atrás
8 meses atrás
8 meses atrás
8 meses atrás
9 meses atrás
8 meses atrás
8 meses atrás
10 meses atrás
8 meses atrás
10 meses atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # WiringPi
  2. WiringPi is a _performant_ GPIO access library written in C for Raspberry Pi boards.
  3. :warning:️ :construction: on Pi5, PWM support is currently under development and _will not work at this point_. If you're interested in the progress, please check the [corresponding issue](https://github.com/GrazerComputerClub/WiringPi/issues/21).
  4. To compile programs with wiringPi, you need to include `wiringPi.h` as well as link against `wiringPi`:
  5. ```c
  6. #include <wiringPi.h> // Include WiringPi library!
  7. int main(void)
  8. {
  9. // uses BCM numbering of the GPIOs and directly accesses the GPIO registers.
  10. wiringPiSetupGpio();
  11. // pin mode ..(INPUT, OUTPUT, PWM_OUTPUT, GPIO_CLOCK)
  12. // set pin 17 to input
  13. pinMode(17, INPUT);
  14. // pull up/down mode (PUD_OFF, PUD_UP, PUD_DOWN) => down
  15. pullUpDnControl(17, PUD_DOWN);
  16. // get state of pin 17
  17. int value = digitalRead(17);
  18. if (HIGH == value)
  19. {
  20. // your code
  21. }
  22. }
  23. ```
  24. To compile this code, link against wiringPi:
  25. ```sh
  26. gcc -o myapp myapp.c -l wiringPi
  27. ```
  28. Be sure to check out the [examples](./examples/), build them using Make:
  29. ```sh
  30. cd examples
  31. make <example-name | really-all>
  32. ```
  33. The tool `gpio` can be used to set single pins as well as get the state of everything at once:
  34. ```
  35. pi@wiringdemo:~ $ gpio readall
  36. +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+
  37. | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
  38. +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
  39. | | | 3.3v | | | 1 || 2 | | | 5v | | |
  40. | 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5v | | |
  41. | 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
  42. | 4 | 7 | GPIO. 7 | IN | 0 | 7 || 8 | 0 | IN | TxD | 15 | 14 |
  43. | | | 0v | | | 9 || 10 | 1 | IN | RxD | 16 | 15 |
  44. | 17 | 0 | GPIO. 0 | IN | 1 | 11 || 12 | 1 | IN | GPIO. 1 | 1 | 18 |
  45. | 27 | 2 | GPIO. 2 | IN | 1 | 13 || 14 | | | 0v | | |
  46. | 22 | 3 | GPIO. 3 | IN | 1 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
  47. | | | 3.3v | | | 17 || 18 | 1 | IN | GPIO. 5 | 5 | 24 |
  48. | 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
  49. | 9 | 13 | MISO | IN | 0 | 21 || 22 | 1 | IN | GPIO. 6 | 6 | 25 |
  50. | 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
  51. | | | 0v | | | 25 || 26 | 0 | IN | CE1 | 11 | 7 |
  52. | 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
  53. | 5 | 21 | GPIO.21 | IN | 0 | 29 || 30 | | | 0v | | |
  54. | 6 | 22 | GPIO.22 | IN | 0 | 31 || 32 | 1 | IN | GPIO.26 | 26 | 12 |
  55. | 13 | 23 | GPIO.23 | IN | 1 | 33 || 34 | | | 0v | | |
  56. | 19 | 24 | GPIO.24 | IN | 1 | 35 || 36 | 1 | IN | GPIO.27 | 27 | 16 |
  57. | 26 | 25 | GPIO.25 | IN | 1 | 37 || 38 | 1 | IN | GPIO.28 | 28 | 20 |
  58. | | | 0v | | | 39 || 40 | 1 | IN | GPIO.29 | 29 | 21 |
  59. +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
  60. | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
  61. +-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+
  62. ```
  63. ## Installing
  64. You can either build it yourself or use the prebuilt binaries:
  65. ### From Source
  66. 1. create debian-package
  67. ```sh
  68. # fetch the source
  69. sudo apt install git
  70. git clone https://github.com/WiringPi/WiringPi.git
  71. cd WiringPi
  72. # build the package
  73. ./build debian
  74. mv debian-template/wiringpi-3.0-1.deb .
  75. # install it
  76. sudo apt install ./wiringpi-3.0-1.deb
  77. ```
  78. ### Prebuilt Binaries
  79. Grab the latest release from [here](https://github.com/WiringPi/WiringPi/releases).
  80. Unzip/use the portable prebuilt verison:
  81. ```sh
  82. # unzip the archive
  83. tar -xfv wiringpi_3.0.tar.gz
  84. ```
  85. Install the debian package:
  86. ```sh
  87. # install a dpkg
  88. sudo apt install ./wiringpi-3.0-1.deb
  89. ```
  90. ## Ports
  91. wiringPi has been wrapped for multiple languages:
  92. * Node - https://github.com/WiringPi/WiringPi-Node
  93. * Perl - https://github.com/WiringPi/WiringPi-Perl
  94. * PHP - https://github.com/WiringPi/WiringPi-PHP
  95. * Python - https://github.com/WiringPi/WiringPi-Python
  96. * Ruby - https://github.com/WiringPi/WiringPi-Ruby
  97. ## Support
  98. Please use the [issue system](https://github.com/WiringPi/WiringPi/issues) of GitHub.
  99. Please do not email Gordon or @Gadgetoid.
  100. Please don't email GC2 for reporting issues, you might [contact us](mailto:wiringpi@gc2.at) for anything that's not meant for the public.
  101. ## History
  102. This repository is the continuation of 'Gordon's wiringPi' which has been [deprecated](https://web.archive.org/web/20220405225008/http://wiringpi.com/wiringpi-deprecated/), a while ago.
  103. * The last "old wiringPi" source of Gordon's release can be found at the
  104. [`final_source_2.50`](https://github.com/WiringPi/WiringPi/tree/final_official_2.50) tag.
  105. * The default `master` branch contains code that has been written since version 2.5
  106. to provide support for newer hardware as well as new features.
  107. :information_source:️ Since 2024, [GC2](https://github.com/GrazerComputerClub) has taken over maintenance of the project, supporting new OS versions as well as current hardware generations. We are dedicated to keeping the arguably best-performing GPIO Library for Raspberry Pi running smoothly. We strive to do our best, but please note that this is a community effort, and we cannot provide any guarantees or take responsibility for implementing specific features you may need.
  108. ## Debug
  109. WIRINGPI_DEBUG=1 ./my_wiringpi_program
  110. WIRINGPI_DEBUG=1 gpio readall