MediaTek LinkIt™ Smart 7688 Duo Get Started Guide
© 2015, 2016 MediaTek Inc.
Page 26 of 27
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly
prohibited.
You won’t see the LED blink at this point yet because it’s waiting for commands on Serial1 from a
program, which you’ll create next.
Step 2: Create a Python program to send commands to the sketch
This program sends the 0 and 1 commands to the ttys0 device periodically. The commands maps
to the Serial1 in the Arduino sketch.
2)
Create a file
blink_on_duo.py
in the system console by typing below command. After the
text editor opens, press the
i
key and go to next step.
# vim blink_on_duo.py
3)
Copy the below example to the editor of
blink_on_duo.py
.
import
serial
import
time
s
=
None
def
setup
():
global
s
# open serial COM port to /dev/ttyS0, which maps to UART0(D0/D1)
# the baudrate is set to 57600 and should be the same as the one
# specified in the Arduino sketch uploaded to ATMega32U4.
s
=
serial.Serial(
"
/dev/ttyS0
"
,
57600
)
def
loop
():
# send "1" to the Arduino sketch on ATMega32U4.
# the sketch will turn on the LED attached to D13 on the board
s.write(
"
1
"
)
time.sleep(
1
)
# send "0" to the sketch to turn off the LED
s.write(
"
0
"
)
time.sleep(
1
)
if
__name__
==
'
__main__
'
:
setup()
while
True
:
loop()
4)
Save the file and exit the editor by typing
:wq!
5)
Run the Python program by typing the below command in the system console.
# python ./blink_on_duo.py
Step 3: Watch the D13 LED on LinkIt Smart 7688 Duo blink
After you’ve executed the Python program and see the D13 LED on LinkIt Smart 7688 Duo blink
every second, you‘ve successfully completed the example.
Next: What’s next?