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.[/vc_column_text][vc_tour][vc_tab title=”Run Python on pcDuino” tab_id=”1393481668-1-4″][vc_column_text]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
[/vc_column_text][/vc_tab][vc_tab title=”Program Python with arduino” tab_id=”1393481668-2-23″][vc_column_text]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() <img alt="image3" src="http://cnlearn.linksprite.com/wp-content/uploads/2014/02/%E5%9B%BE%E7%89%8735.png" />