Linkit Smart Duo: Blinking a LED with Python

The objective of this post is to explain how to interface with the Linkit Smart Duo hardware from Python to blink the LED of the board.


Introduction

The objective of this post is to explain how to interface with the Linkit Smart Duo hardware from Python to blink the LED of the board.

To do so, we will use a module called MRAA, which comes pre-installed in the board. This module allows to control the peripherals of the Linkit Smart Duo board with easy to use functions.

But, first of all, we need to connect to the board through SSH. You can check a detailed guide on how to do it here.


Using MRAA

Once connected to the Linkit Smart Duo, we can start playing with the MRAA module. To keep things simple, we will use this library from Python’s command line.

To start Python’s command line, just type python and press enter. You should get something similar to figure 1.

linkit-smart-duo-python-command-line

Figure 1 – Python command line.

For the actual Python code, we will now detail the commands needed. First, we will import the MRAA module.

import mraa

Now, we will initialize the GPIO corresponding to the WiFi LED pin (the orange one), which corresponds to GPIO 44 [1].

led = mraa.Gpio(44)

Then, we declare it as output with the code bellow.

led.dir(mraa.DIR_OUT)

Finally, we can controle the state of the pin (High or Low) with the write method.

led.write(1)
led.write(0)

Switching between one or another will make the orange LED blink, as we expected.

You can check the command line outputs in figure 2.

linkit-smart-duo-mraa-in-python

Figure 2 – Running the LED control command on Python’s command line.

 

Related Content


Related Posts

 

References

[1] https://labs.mediatek.com/site/global/developer_tools/mediatek_linkit_smart_7688/training_docs/peripherals/mraa_python/index.gsp

Advertisements
This entry was posted in LinkIt Smart and tagged , , , , , , , , . Bookmark the permalink.

3 Responses to Linkit Smart Duo: Blinking a LED with Python

  1. Pingback: LinkIt Smart Duo: Connecton to WiFi Network | techtutorialsx

  2. Pingback: LinkIt Smart Duo: Transferring files with SCP | techtutorialsx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s