Lab 1: Set up Arduino

Part 1: Set up Arduino and test your MAiX BiT board with Blinker

1. Configuring Arduino and MAiXduino

Start the Arduino application by clicking its icon. The Arduino IDE has the following features:

IDE

Open Arduino Preferences, then paste the following URL into "Additional Boards Manager URLs" (if there are existing URLs in the field, separate them with a comma ","):

http://dl.sipeed.com/MAIX/Maixduino/package_Maixduino_k210_index.json

image-20190922211141372

Open Boards Manager under Tools>Board. In the newly opened window, wait for the progress bar at the bottom to finish loading.

image-20190922211605650

Enter "maix" in the search box, and install Maixduino(k210) by Sipeed. Make sure you select version 0.3.10 (the newest one). This is what it looks like after install is finished:

image-20190922212024831

Close Boards Manager. Now you should see Sipeed Maix Bit-Mic Board under Tools>Board. Select it:

image-20190922212459315

Now we want to change the burn baud rate. Maixduino provided two configurations for this board: 1.5 Mbps and 1 Mbps. However, both are too fast for our Maix Bit board. In practice, I find 500 kbps to be a reliable speed to write to the board. In order to change that, we have to modify the configuration file supplied by Maixduino.

As we are changing the configuration file, first quit Arduino. In your favorite text edior, open /Users/<username>/Library/Arduino15/packages/Maixduino/hardware/k210/0.3.10/boards.txt (for macOS) or C:\Users\<username>\AppData\Local\Arduino15\packages\Maixduino\hardware\k210\0.3.10\boards.txt (for Windows). Note: change <username> into your actual user name.

Starting from line 118, you should find configurations for burn baud rates for the Maix Bit-Mic board. Add the following lines:

image-20190922213501975

Save the fie. Now launch Arduino again. You should see 500 kbps listed under Tools>Burn Baud Rate. Select it.

Then, select the correct serial port to communicate with the board. (it may have some different name depending on your PC):

image-20190922213837623

Finally, choose k-flash under Tools>Programmer:

image-20190922214103599

2. Modifying and compiling the Blinker code

Open the Blink example under File>Examples>01.Basics:

image-20190922214338750

Press the Upload button in Arduino to compile and upload the Blink program. You should see the LED next to the USB port blinking after Arduino is done uploading.

Now, look at the program code, and see if you can speed up the blink rate. Demonstrate your new blink rate to a TA.

Now, save your changed sketch. The system will require you to save the sketch in your own workspace, usually on your Z: drive. As a safety measure, you may want to back up your work to a thumb drive that you can use elsewhere.

Congratulations! You've just built and tested your first MAiX BiT application.

Part 2: Draw shapes and text on the LCD

  1. Open the basic_graphics.ino example program from Arduino.

  2. Compile and load the sketch.

  3. Read the example code and compare it to the results on the Maix Bit LCD. Modify the code to change the position and size of the elements shown. Refer to the following libraries for more information:

    Maixduino: https://github.com/sipeed/Maixduino/tree/master/libraries/Sipeed_ST7789/src

    Adafruit GFX: https://github.com/adafruit/Adafruit-GFX-Library

  4. Open the graphicstest.ino example program from Arduino.

  5. Open Serial Monitor under the Tools menu. Make sure to choose the correct baud rate that matches the code.

    image-20190922234725686

  6. Compile and load the sketch.

  7. After the program starts running, check Serial Monitor for serial output. Look at the Maix Bit display. Find two screens (or animations) that are interesting to you. Find and read the code that draws them.

Part 3: Display images from the camera on the LCD and draw a rectangle

  1. Open the selfie.ino example program from Arduino.
  2. Compile and load the sketch.
  3. You should see images from the camera being displayed on the LCD. Refer to the code samples in Part 2, edit the code so that it draws a 60x40 rectangle in the center of the screen. Demonstrate your changes to a TA.