Create and run your first example

Your’re now ready to run a Arduino sketch. In this example the Arduino sketch listens on the Serial1 port for commands issued from the Linux side using a Python program. Each time a command is received from the Python program on the Serial1 port the sketch changes the status of the D13 LED on the board.

To complete this section, you’ll:

  • Upload an Arduino sketch to the LinkIt Smart 7688 Duo board.
  • Create a Python program and run it.
  • Watch the D13 LED blink.

Next: What Next on LinkIt Smart 7688 Duo?

Step 1 — Upload an Arduino sketch to LinkIt Smart 7688 Duo development board

  • Open Arduino IDE and on the File menu click New, then copy and paste in the following code:

          void setup() { 
              Serial.begin(115200);  // open serial connection to USB Serial 
                                     //port(connected to your computer)
              Serial1.begin(57600);  // open internal serial connection to 
              pinMode(13, OUTPUT); // in MT7688, this maps to device 
          void loop() { 
                int c =;      // read from MT7688
                if (c != -1) {
                      switch(c) { 
                            case '0':                // turn off D13 when receiving "0"
                            digitalWrite(13, 0); 
                            case '1':                // turn on D13 when receiving "1" 
                            digitalWrite(13, 1); 
  • Upload the sketch to the board. 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 port in the Arduino sketch.

  • Create a file called in the system console by typing vim
  • After the text editor opens, press the i key.
  • Copy the following code into the editor:

    import serial
    import time
    s = None
    def setup():
        # 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.
        global s
        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
        # send "0" to the sketch to turn off the LED
    if __name__ == '__main__':
        while True:
  • Save the file and exit the editor by pressing the Esc key followed by :wq!.
  • Run the Python program by typing python ./ in the system console.

Step 3 — Watch the D13 LED on the LinkIt Smart 7688 Duo board blink

After you’ve executed the Python program you’ll see the D13 LED on LinkIt Smart 7688 Duo board blink every second.

Congratulations. You have now run your first sketch on the LinkIt Smart 7688 development board. Now you can find some suggestions on what to do next.

Next: What Next on LinkIt Smart 7688 Duo?