DESK-MX6-L/Development/Application examples/Hello world Python example

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2024/06/12 DESK-MX6-L-4.x.x release



Hello world Python example[edit | edit source]

Here below an example of Python code displaying the classic Hello World! message on the target serial console.

Python3 environment[edit | edit source]

In the DESK-MX6-L development environment, python3 package has been already installed in the Yocto dave-image-devel target image.

For more information on using Python in the DESK-MX6-L see this Application Note

root@desk-mx6:~# python3
Python 3.10.7 (main, Sep  5 2022, 13:12:31) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

It is enough to create the the hello.py Python source code file:

root@desk-mx6:~# echo 'print("Hello, World!")'  > hello.py
root@desk-mx6:~#

and execute it by invoking Python3:

root@desk-mx6:~# python3 hello.py
Hello, World!
root@desk-mx6:~#

Python usage[edit | edit source]

Here an example of how using Python for toggling a GPIO (connected to a LED).