MicroMod Qwiic Pro Kit Project Guide

Pages
Contributors: bboyho
Favorited Favorite 0

Example Code

We recommend grabbing the code from its the GitHub repository. Otherwise, you can download the zipped file from the link below.

After downloading, unzip the files and open the MicroModQwiicStarterExample.ino sketch. It should be located in the downloads folder similar to this path: .../Firmware/Arduino/MicroModQwiicStarterExample/MicroModQwiicStarterExample.ino. Open the code up in the Arduino IDE, select the board (i.e. the SparkFun SAMD51 MicroMod), and the COM port that the board enumerated on. Then hit the upload button.

With a friend, try rocking the 9DoF back and forth along the x-axis or moving your hand above the proximity sensor to control each paddle. You can also take a PCB or flat object as shown in the GIF below to make it easier to control. Remember, you will need to orient the 9DoF's accelerometer with respect to the paddle (if you notice in the GIF, player 1 had the board oriented in a way that had the paddle controls were reversed). You will need to orient the micro OLED so that the paddle is on the side of the player's Qwiic board. The game will continue as long as the ball hits the paddle and bounces to the other side. A player will win a round as soon as the other player fails to bounce the ball back to the other side. The current score will be briefly displayed before the next game. Try to rack up more points than your opponent!

MicroPong Demo with MicroMod Qwiic Pro Kit

The default code uses the 9DoF's accelerometer as player 1 and the proximity sensor as player 2. Try adjusting the code to use the joystick for one of the players by adding and removing the single line comments. The joystick will control the paddle along the "vertical" y-axis. Each board can only have one player assigned. See if you can try to remove the unused Qwiic board from the daisy chain and commenting out each instance of the related board. Or try adjusting the code to control the paddle with the magnetometer and a magnet!