8,367
edits
Changes
→40pin GPIO port test
# The following takes pin No. 7—the corresponding GPIO is GPIO4_C3—the corresponding wPi number is 2—as an example to demonstrate how to set the high and low levels of the GPIO port
::[[File:cm4-img257.png]]
<ol start="2" style="list-style-type: decimal;">
<li><p>The steps to test directly with the command are as follows</p>
<ol style="list-style-type: lower-alpha;">
<li>First set the GPIO port to output mode, where the first parameter of the '''pinMode''' function is the serial number of the wPi corresponding to the pin, and the second parameter is the GPIO mode</li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~/wiringOP-Python# '''python3 -c "import wiringpi; \'''
'''from wiringpi import GPIO; wiringpi.wiringPiSetup() ; \'''
'''wiringpi.pinMode(<span style="color:#FF0000">2, GPIO.OUTPUT</span>) ; "'''|}</ol>
<ol start="2" style="list-style-type: lower-alpha;">
<li>Then set the GPIO port to output low level. After setting, you can use a multimeter to measure the voltage value of the pin. If it is 0v, it means that the low level is set successfully.</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~/wiringOP-Python# '''python3 -c "import wiringpi; \'''
'''from wiringpi import GPIO; wiringpi.wiringPiSetup() ;\'''
'''wiringpi.digitalWrite(<span style="color:#FF0000">2, GPIO.LOW</span>)"'''|}</ol>
<ol start="3" style="list-style-type: lower-alpha;">
<li>Then set the GPIO port to output a high level. After setting, you can use a multimeter to measure the voltage value of the pin. If it is 3.3v, it means that the high level is set successfully.</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~/wiringOP-Python# '''python3 -c "import wiringpi; \'''
'''from wiringpi import GPIO; wiringpi.wiringPiSetup() ;\'''
'''wiringpi.digitalWrite(<span style="color:#FF0000">2, GPIO.HIGH</span>)"'''|}</ol></li></ol>
<ol start="3" style="list-style-type: decimal;">
<li><p>The steps to test in the python3 command line are as follows:</p>
<ol style="list-style-type: lower-alpha;">
<li>First use the python3 command to enter the command line mode of python3</li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~# '''python3'''
|}</ol>
<ol start="2" style="list-style-type: lower-alpha;">
<li>Then import the python module of wiringpi</li></ol>{| class="wikitable" style="width:800px;" |-|
>>> '''import wiringpi'''
>>> '''from wiringpi import GPIO'''
|}</ol>
<ol start="3" style="list-style-type: lower-alpha;">
<li>Then set the GPIO port to output mode, where the first parameter of the '''pinMode''' function is the serial number of the wPi corresponding to the pin, and the second parameter is the GPIO mode</li></ol>{| class="wikitable" style="width:800px;" |-|
>>> '''wiringpi.wiringPiSetup()'''
0
>>> '''wiringpi.pinMode(<span style="color:#FF0000">2, GPIO.OUTPUT</span>)'''|}</ol>
<ol start="4" style="list-style-type: lower-alpha;">
<li>Then set the GPIO port to output a low level. After setting, you can use a multimeter to measure the voltage value of the pin. If it is 0v, it means that the low level is set successfully.</li></ol>{| class="wikitable" style="width:800px;" |-| >>> '''wiringpi.digitalWrite(<span style="color:#FF0000">2, GPIO.LOW</span>)'''|}</ol>
<ol start="5" style="list-style-type: lower-alpha;">
<li>Then set the GPIO port to output a high level. After setting, you can use a multimeter to measure the voltage value of the pin. If it is 3.3v, it means that the high level is set successfully.</li></ol>{| class="wikitable" style="width:800px;" |-| >>> '''wiringpi.digitalWrite(<span style="color:#FF0000">2, GPIO.HIGH</span>)'''|}</ol></li></ol>
<ol start="4" style="list-style-type: decimal;">
<li>The method of setting GPIO high and low levels in the python code by wiringOP-Python can refer to the '''blink.py''' test program in the examples below. The '''blink.py''' test program will set the voltage of all GPIO ports in the 40 pins of the development board to change continuously.</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~/wiringOP-Python# '''cd examples'''
root@orangepi:~/wiringOP-Python/examples# '''ls blink.py'''
'''<span style="color:blue">blink.py</span>'''
root@orangepi:~/wiringOP-Python/examples'''# python3 blink.py'''
|}</ol>
<span id="pin-spi-test-1"></span>