[vc_row][vc_column][vc_column_text]GPIO is short for General Purpose Input Output, and it can also be called bus extender, Use I2C, SMBus or industrial
standard SPI interface simplifies the I/O port extension. It uses industrial standard Use I2C, SMBus or industrial
standard SPI interface simplifies the I/O port extension I2C, SMBus or SPI interface to simplify the I/O extension.
When the Micro controller or chipset do not have enough I/O port, or when system need to adopt the remote serial to
communicate or control.
GPIO product could offer the unction of extra control or monitor This post will introduce how to use the python to
control GPIO on pcDuino.[/vc_column_text][vc_tour][vc_tab title=”Part list” tab_id=”1394422133-1-61″][vc_column_text]1. [bigcommerce link=”/pcduino-v2-an-minipc-with-arduino-headers-ubuntu-android-google/” target=”_blank”]pcDuino V2[/bigcommerce] x1
2. [bigcommerce link=”/5mm-blue-led-module-of-linker-kit-for-pcduino-arduino/” target=”_blank”]Linker LED[/bigcommerce] x1
3. [bigcommerce link=”/base-shield-of-linker-kit-for-pcduino-arduino/” target=”_blank”]Linker Base[/bigcommerce] x1
4. [bigcommerce link=”/20-cm-cable-for-linker-kit/” target=”_blank”]Linker cable[/bigcommerce] x1[/vc_column_text][/vc_tab][vc_tab title=”Wiring Diagram” tab_id=”1394422133-2-36″][vc_column_text][/vc_column_text][/vc_tab][vc_tab title=”Running test” tab_id=”1394488118221-2-0″][vc_column_text]
(1)Download the python library file on pcDuino:
$git clone https://github.com/pcduino/python-pcduino.git
(2)Enter into python-pcduino,you can see two fold under the current directory, and under the Samples directory it contains two official routine. And enter into the directory Samples/blink_led/gpio, you will see one file named”__init__.py”, it contains some basic Arduino function:
(3)Create a file named linker_led in directory Sample and copy the gplo file in blink_led to the linker_led directory:
$mkdir linker_led $cd linker_led $cp /home/ubuntu/python-pcduino/Samples/blink_led/gpio ./ -rf
(4)Create a linker_led.py file under directory linker_led, and input the following test code:
$vim linker_led.py
#Test Code : import gpio from time import sleep led_pin = "gpio2" def delay(ms): sleep(1.0*ms/1000) def setup(): gpio.pinMode(led_pin, gpio.OUTPUT) def loop(): while(1): gpio.digitalWrite(led_pin, gpio.HIGH) delay(200) gpio.digitalWrite(led_pin, gpio.LOW) delay(200) setup() loop()
(5)Run the code and display the result:
$python ./linker_led.py
[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.