Run Python code at Pcduino

From ElectroDragon
Jump to: navigation, search

Install the Git firstly

Clone the files from here: https://github.com/pcduino/python-pcduino
Clone python files.png

See what is in the python folder
See what is in the python folder.png

Run the python code, with the following command

ubuntu@ubuntu:~/python-pcduino/Samples/blink_led$ python blink_led.py

And this code will run

#!/usr/bin/env python
# blink_led.py
# gpio test code for pcduino ( http://www.pcduino.com )
#
import gpio
import time
 
led_pin = "gpio18"
 
def delay(ms):
    time.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(100)
 
def main():
    setup()
    loop()
 
main()

Python LED.jpg