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.
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.
Figure 2 – Running the LED control command on Python’s command line.
Related Content
Related Posts
Awesome!
Awesome!
Pingback: LinkIt Smart Duo: Connecton to WiFi Network | techtutorialsx
Pingback: LinkIt Smart Duo: Connecton to WiFi Network | techtutorialsx
Pingback: LinkIt Smart Duo: Transferring files with SCP | techtutorialsx
Pingback: LinkIt Smart Duo: Transferring files with SCP | techtutorialsx