Raspberry pie gpio interface and programming method

The Raspberry Pi is getting more and more hot, and the online Raspberry Pi has more and more information. The Raspberry Pi originated from the United Kingdom, and the embedded open source field in foreign countries has a good sharing spirit. The various integrated libraries of the Raspberry Pi are also emerging one after another. The following describes the raspberry pie gpio interface and programming method in detail.

Raspberry pie gpio interface and programming method

GPIO basic introduction

GPIO (GeneralPurposeI/OPorts) means a general-purpose input/output port. In layman's terms, there are pins that can be output high or low or through which they are read into the pin - high or low. GPIO is a relatively important concept. Users can perform data interaction (such as UART) through GPIO port and hardware, control hardware work (such as LED, buzzer, etc.), and read hardware working status signals (such as interrupt signals). The GPIO port is very widely used. Mastering GPIO is almost equivalent to mastering the ability to operate hardware.

Raspberry pie gpio interface and programming method

As you can see on the figure, each pin has a Pin# and NAME fields. Pin represents the number of the pin, where pins 01 and 02 correspond to the two pins on the far right of the GPIO in the first figure. NAME stands for the BCM name of the pin. Of course, NAME can also directly see the default function of the pin. For example, 3.3v and 5v mean that the pin will output 3.3v and 5v, Ground means the pin is grounded, and GPIO0* is some pin to be developed by the user. Each pin can be controlled using a program.

   GPIO number

Raspberry pie gpio interface and programming method

Operating the GPIO port of the Raspberry Pi, the GPIO number exists in three different ways.

1, socket numbering method

The number focuses on the side of the P1 socket, from top to bottom, from left to right. Just like the Header column of the figure.

2, BCM2835 numbering method

The number focuses on the CPU register, according to the GPIO register number of the BCM2835. As shown in the figure BCMGPIO column.

3, wiringPi numbering method

The numbering focuses on the implementation logic, numbering the extended GPIO ports from 0, which is easy to program. As shown in the figure WiringPi.

GPIO code writing
Raspberry pie gpio interface and programming method

1, written directly in the Raspberry Pi

There are several code (text) editing software in the Raspberry Pi that can write code in the Raspberry Pi.

2, written in windows

You can write code in windows. If it is a Python script, you can transfer it to the Raspberry Pi via FTP software, and then use the SSH client to log in to the Raspberry Pi to execute the Python script. If it is a C language file, in addition to using FTP transfer, you need to compile on the Raspberry Pi to generate an executable file (equivalent to the exe file on Windows).

3, written in other linux

Unlike writing code in windows, cross-toolchains can be installed in other Linux distributions (such as ubuntu), cross-compiled C files are generated in the Raspberry Pi executable file, then FTP can be used to transfer executable files to the Raspberry Pi. . In fact, Mode 1 and Mode 3 are almost the same.

5.1 Home Theater Speaker

5.1 Home Theater Speaker,Home Theatre 5.1,Wireless Surround Sound Speakers,Bluetooth Surround Sound System

GUANGZHOU SOWANGNY ELECTRONIC CO.,LTD , https://www.jerry-power.com

This entry was posted in on