• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeStarter Kit for pcDuino8 Uno User Guide4.Introduction of Python on pcDuino8 Uno4.Chapter 4 Introduction of Python on pcDuino8 Uno
Previous Next

4.Chapter 4 Introduction of Python on pcDuino8 Uno

Posted by: Olva , August 10, 2016

Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.

Python is pre-installed in the pcDuino8 Uno Ubuntu image. The sample python code can be downloaded from: https://github.com/pcduino/python-pcduino

git clone https://github.com/pcduino/python-pcduino

Cloning into ‘python-pcduino’…
remote: Counting objects: 123, done.
remote: Total 123 (delta 0), reused 0 (delta 0), pack-reused 123
Receiving objects: 100% (123/123), 28.66 KiB | 0 bytes/s, done.
Resolving deltas: 100% (36/36), done.
Checking connectivity… done.

Let’s look around, and what’s inside:

cd python-pcduino
ls

README.md Samples hello-temp pcduino setup.py weblamp

Let’s look at the sample project blink_led.We will blink LED7 which connects to GPIO18.

The python code is shown below:

#!/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()

To execute the code, we run the following command:

python Samples/blink_led/blink_led.py

We can observe Linker LED module blinking.

Share!
Tweet

Olva

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors