Original: http://blog.csdn.net/xukai871105/article/details/12684617 Raspberry Pi from abroad, foreign embedded open source field has a good sharing spirit, Raspberry Pi Various integrated libraries are also emerging, the following recommended several. "Python GPIO" (the more precise name of the library should be Raspberry-gpio-python)
Simple Introduction: Recommended and easy to get started in the Raspberry Pi official profile. Python gpio is a small Python library that can help users complete raspberry related IO port operations. But the Python Gpio library Alsono support for bus interfaces such as SPI, I²c, or 1-wire。 In addition to Python gpio, there are a number of Python extensions (such as Webiopi), and there's no question that Python is perfect for Raspberry Pi, and the Raspberry Pi is perfect for python. "Wiringpi"
Simple Introduction: The programming method is compatible with Arduino, the author gives a lot of instructions and sample code, powerful. These sample codes Alsoincluding UART devices, i²c devices and SPI devices, etc.。 "BCM2835 C Library"
Simple Introduction: The C library can be understood as the underlying driver for C language implementation,includes Gpio, SPI, i²c and UART, etc., easy and easy to use. RASPI extension: 1.raspi extended by I²c and PCF8574 8 i/o,1 i2c:8 pcf8574:64 i/o//bcm2835lib (bought) can use MCP23X17/MCP23X08 (i²c or SPI) Extended Gpio Interface//wiringpi Lib III, WIRINGPI installation: (Introduction, PIN description) original address: http://blog.csdn.net/xukai871105/article/details/17737005
1.WiringPi IntroductionWIRINGPI is a Gpio control library function applied to the Raspberry Pi platform, and WIRINGPI complies with the gun Lv3. WIRINGPI is developed using C or C + + and can be transferred to other languages, such as Python, Ruby, or PHP. The functions in WIRINGPI are similar to the Arduino wiring system, which makes it easier for users familiar with Arduino to use WRINGPI. The Raspberry Pi has 26 common input and output pins. With 8 common input and output pins in these 26 pins, these 8 pins can be both input pins and output pins. In addition, the Raspberry Pi also has a 2-wire form of i²c, a 4-wire form of SPI and a UART interface. The I²c and SPI interfaces on the Raspberry Pi can also be used as normal ports. If the serial console is turned off, you can use the UART function on the Raspberry Pi. If you do not use multiplexed interfaces such as I2C,SPI and UART, the Raspberry Pi has a total of 8+2+5+2 = 17 ordinary io. The WIRINGPI includes a set of GPIO control commands that use the GPIO command to control the Raspberry Pi Gpio pin. The Gpio command allows the user to control or query the Gpio pins through a shell script. The WIRINGPI is extensible and can be extended using the WIRINGPI's internal module to extend the analog input chip, and the Gpio interface can be extended with mcp23x17/mcp23x08 (I²c or SPI). Additional GPIO functions can be extended via the serial port on the Raspberry Pi and atmega (such as Arduino). In addition, users can write their own extension modules and integrate their custom extensions into the WIRINGPI. The WIRINGPI supports analog read and setup functions, but there is no analog device on the Raspberry Pi. But using the software modules in WIRINGPI makes it easy to apply ad or Da chips.
for richer content, please refer to--"Raspberry Pi Study notes-index blog post"
2.wiringPi InstallationWIRINGPI installation exists in scenario A and scenario B. WIRINGPI uses GIT tools to maintain the updated code, but if you can't use git for some other reason, you can also use scenario B to download and install WIRINGPI.
scenario a--using git toolsIf you do not have the Git tool installed on your platform, you can enter the following command:
sudo apt-get install Git-coreIf an error occurs during this process, try to update the software, for example, enter the following command:
sudo apt-get update
sudo apt-get upgradeThe WIRINGPI source code can then be obtained via Git
git clone GIT://GIT.DROGON.NET/WIRINGPI//will create Wiringpi folder in the current directory, I installed in/home/pi/wiringpi/directoryEnter the WIRINGPI directory and install WIRINGPI
CD wiringpi/
./buildThe build script will help you compile and install WIRINGPI if you need to update WIRINGPI.
CD WIRINGPI
git pull OriginIn the shell input Gpio will output the Gpio available command options in the/wiringpi/examples directory there are some examples, such as Test1, which run the following sudo./test1
solution b--Direct download and decompressionSimply enter the following URL: https://git.drogon.net/?p=wiringPi;a=summary Figure 1 Download wiringpi latest version source code click on the snapshot in the diagram to download the latest version. You may be downloading to a compressed package called wiringpi-98bcb20.tar.gz, and the need to help is that 98BCB20 is just a version number that may change when you download WIRINGPI. You need to extract the WIRINGPI source code and install it, you can enter the following instructions:
tar xfz wiringpi-98bcb20.tar.gz
CD Wiringpi-98bcb20
./buildAgain, the name of the WIRINGPI compressed package
It's probably not 98bcb20 ., please change according to the actual situation.
Test if the WIRINGPI is installed successfullyThe WIRINGPI includes a set of GPIO commands that can be used to control various interfaces on the Raspberry Pi using the GPIO command to test whether the WIRINGPI is successfully installed.
gpio-v
Gpio ReadAllFigure 2 Test WIRINGPI If the installation was successful
3. Pin Descriptionis the pin description of the WIRINGPI, it is necessary to explain two points. The first Raspberry Pi exists version A and version B, the Gpio pins of version A and version B are different; second, wiringpi the Raspberry Pi pins, for example WIRINGPI's GPIO0 means BCM2835 GPIO17, which is just a package mapping relationship, Does not have a significant impact on development and use. Figure 3 Mapping relationship between the WIRINGPI pin and the BCM Pin
4. References1. Raspberry Pi Learning Note--gpio Functional learning 2. Raspberry Pi Study notes--I2C using PCF8574