After the python test in the previous article
LEDE on Linkit 7688 Duo – MPU-MCU Uart communication
here we describe how to do the same operation using the Firmata python library
In this case, the programming model is the following
As first step, described in the Mediatek article
we install the Firmata python library; in a linux terminal on LEDE run
1 |
pip install pyfirmata |
In the Arduino IDE choose File->Examples->Firmata->StandardFirmata
Make the following change in sketch code:
Look for the code
Firmata.begin(57600);
while (!Serial) {
and replace it with
Serial1.begin(57600);
Firmata.begin(Serial1);
while (!Serial1) {
Save the file and perform the compilation and upload on the Linkit 7688 Duo.
In a linux terminal in Lede create the blink_with_firmata.py file and copy the following code inside
1 2 3 4 5 6 7 8 9 10 |
from pyfirmata import Arduino, util from time import sleep board = Arduino('/dev/ttyS0') print "Start blinking D13" while True: board.digital[13].write(1) sleep(0.5) board.digital[13].write(0) sleep(0.5)<span class="kwd"> </span> |
Save and quit.
Always in a linux terminal run now
1 |
python ./blink_with_firmata.py |
The LED on the card should turn on and off.
Below is the link to download the two files ready for the Link 7688 Duo
In the next article we’ll enable the board to work like Arduino Yun