Python:Run Python on PcDuino

Published

Introduction: Python:Run Python on PcDuino

About: Let's play together! All about pcDuino,Arduino,Raspberry pi and technology. My facebook :Sherry Wu https://m.facebook.com/sasha.wu.775

Python is a widely used general-purpose, high-level
programming language.Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C.The language provides constructs intended to enable clear programs on both a small and large scale.

Python supports multiple programming paradigms, including object-oriented, imperative and functional programming orprocedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library.

Like other dynamic languages, Python is often used as a scripting language, but is also used in a wide range of non-scripting contexts. Using third-party tools, such as Py2exe, or Pyinstaller,Python code can be packaged into standalone executable programs. Python interpreters are available for many operating systems.

Step 1:

Python is preloaded in pcDuino 20130531 and later version. (The example program of Python can be download on the github).
Here with a ‘ HelloWord’ program to introduce how to use the Python on pcDuino)

(1) Create a file named as helloword.py

$ vim helloword.py

(2)Write simple Python code in the new file ‘.py’ .

print (“Hello Word !”)

(3)Run the script of Python.
$ python ./helloword.py

Step 2:

Following is a simple routine:Let variable value add 1 every 1s, add to 256 then reset to zero

import time
i = 0 disp_delay = 0 def delay(ms): time.sleep(1.0*ms/1000) def setup(): global i,disp_delay i = 0 disp_delay = 1000 def loop(): global i,disp_delay i = i + 1 if(i == 256): i = 0; print ("i = %d" %i) delay(disp_delay) #main function setup() while True: loop()

Share

    Recommendations

    • Woodworking Contest

      Woodworking Contest
    • Clocks Contest

      Clocks Contest
    • Planter Challenge

      Planter Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments

    Is this instructable done? Are you still working on it?