Open main menu

Wiki-Orange Pi β

Changes

Orange Pi Zero 2W

698 bytes added, 11:19, 26 September 2023
40pin GPIO port test
=== 40pin GPIO port test ===
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big>'''Like wiringOP, wiringOP-Python can also determine which GPIO pin to operate by specifying the wPi number. Because there is no command to view the wPi number in wiringOP-Python, you can only view the board's wPi number and physics through the gpio command in wiringOP Correspondence of pins.'''</big>
[[File:zero2w-img170.png|center]]|}
<ol style="list-style-type: decimal;">
<li><p>The steps for testing directly with commands are as follows:</p>
<ol style="list-style-type: lower-alpha;">
<li><p>First set the GPIO port to output mode, where the first &gt; parameter of the '''pinMode''' function is the serial number of &gt; the wPi corresponding to the pin, and the second parameter is &gt; the GPIO mode.</p>{| class="wikitable" style="width:800px;" |-|
<p>root@orangepi:~/wiringOP-Python# '''python3 -c &quot;import wiringpi; \'''</p>
<p>'''from wiringpi import GPIO; wiringpi.wiringPiSetup() ; \'''</p>
<p>'''wiringpi.pinMode(<span style="color:#FF0000">2, GPIO.OUTPUT</span>) ; &quot;'''</p>|}</li><li><p>Then set the GPIO port to output a low level. After setting, you &gt; can use a multimeter to measure the voltage value of the pin. &gt; If it is 0v, it means the low level is set successfully.</p>{| class="wikitable" style="width:800px;" |-|
<p>root@orangepi:~/wiringOP-Python# '''python3 -c &quot;import wiringpi; \'''</p>
<p>'''from wiringpi import GPIO; wiringpi.wiringPiSetup() ;\'''</p>
<p>'''wiringpi.digitalWrite(2, <span style="color:#FF0000">GPIO.LOW</span>)&quot;'''</p>|}</li><li><p>Then set the GPIO port to output a high level. After setting, &gt; you can use a multimeter to measure the voltage value of the &gt; pin. If it is 3.3v, it means the setting of the high level is &gt; successful.</p>{| class="wikitable" style="width:800px;" |-|
<p>root@orangepi:~/wiringOP-Python# '''python3 -c &quot;import wiringpi; \'''</p>
<p>'''from wiringpi import GPIO; wiringpi.wiringPiSetup() ;\'''</p>
<p>'''wiringpi.digitalWrite(2, <span style="color:#FF0000">GPIO.HIGH</span>)&quot;'''</p>|}</li></ol>
</li>
<li><p>The steps for testing in the command line of python3 are as follows:</p>
<ol style="list-style-type: lower-alpha;">
<li><p>First use the python3 command to enter the command line mode of &gt; python3</p>{| class="wikitable" style="width:800px;" |-| <p>root@orangepi:~# '''python3'''</p>|}</li>
<li><p>Then import the python module of wiringpi</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>&gt;&gt;&gt; '''import wiringpi'''</p>
<p>&gt;&gt;&gt; '''from wiringpi import GPIO'''</p>|}</li><li><p>Then set the GPIO port to output mode, where the first parameter &gt; of the '''pinMode'''function is the serial number of the wPi &gt; corresponding to the pin, and the second parameter is the GPIO &gt; mode.</p>{| class="wikitable" style="width:800px;" |-|
<p>&gt;&gt;&gt; '''wiringpi.wiringPiSetup()'''</p>
<p>0</p>
<p>&gt;&gt;&gt; '''wiringpi.pinMode(<span style="color:#FF0000">2, GPIO.OUTPUT</span>)'''</p>|}</li><li><p>Then set the GPIO port to output a low level. After setting, you &gt; can use a multimeter to measure the voltage value of the pin. &gt; If it is 0v, it means the low level is set successfully.</p>{| class="wikitable" style="width:800px;" |-| <p>&gt;&gt;&gt; '''wiringpi.digitalWrite(2, <span style="color:#FF0000">GPIO.LOW</span>)'''</p>|}</li><li><p>Then set the GPIO port to output a high level. After setting, &gt; you can use a multimeter to measure the voltage value of the &gt; pin. If it is 3.3v, it means the setting of the high level is &gt; successful.</p>{| class="wikitable" style="width:800px;" |-| <p>&gt;&gt;&gt; '''wiringpi.digitalWrite(2, <span style="color:#FF0000">GPIO.HIGH</span>)'''</p>|}</li></ol>
</li>
<li><p>For wiringOP-Python to set the GPIO high and low levels in the python code, you can refer to the '''blink.py''' test program in the examples. The '''blink.py''' test program will set the voltage of all GPIO ports in the 40 Pin of the development board to continuously change high and low.</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>root@orangepi:~/wiringOP-Python# '''cd examples'''</p>
<p>root@orangepi:~/wiringOP-Python/examples# '''ls blink.py'''</p>
<p>'''blink.py'''</p>
<p>root@orangepi:~/wiringOP-Python/examples'''# python3 blink.py'''</p>|}</li></ol>
<span id="pin-spi-test-1"></span>
 
=== 40pin SPI test ===