First, head to the Maker.MakeCode site in your web browser. This version of MakeCode is in beta as of the writing of this guide, and it expands the available boards beyond the Circuit Playground Express to include the Gemma M0, Trinket M0, Metro M0 Express, and Feather M0 Express.
If you're building this project with a Circuit Playground Express, go to the 'regular' MakeCode website, and just skip the first step where you pick which board to use.
Click on the Gemma M0 image to select it.
Now, click the New Project button to create a new program using the Gemma M0.
This is the default MakeCode screen. On the left is the simulator which can be used to test your program before uploading it to the Gemma M0.
In the center is the palate of programing block categories.
On the right is the canvas where you'll drag blocks to create your program.
While there is plenty you can do with the default blocks in MakeCode, sometimes you need to add an extension for special behavior. Click on the Advanced item in the category palette, then click on Extensions.
Next, click on the mouse extension. As it says, this will add blocks capable of USB mouse emulation over HID.
This will add a mouse category to the palette -- click on it, then drag to the canvas a mouse move x 0 y 0 block.
Place the mouse move block inside the forever block. Change the values from
Then, from the loop category, add a pause 500 block as shown, and change the value to
5000 milliseconds. This will cause the cursor to move every five seconds.
This is a good time to test out your code! Give the program a name, such as 'Mouse_Jiggler' and then press the Download button and save the file to a convenient location on disk.
Plug your Gemma M0 into the computer with the USB cable and then press the reset button on the board to enter bootloader mode. The USB disk will show up as GEMMABOOT.
Drag the .uf2 file you saved onto the Gemma M0.
Now, wait five seconds and then watch your cursor move all on it's own!
This is pretty good, but we can increase the fun by making a repeating back-and-forth loop.
Duplicate your existing pause and mouse move blocks and arrange them as shown. Adjust the values as follows, from top to bottom:
repeat 7 times
mouse move x 22 y -9
mouse move x -22 y 9
Download this new version and then upload it to your Gemma M0. Now, every five seconds, the mouse cursor will wiggle back and forth quite a bit seven times and then stop, repeat forever!
Before you deploy this prank on your victim, increase the delay time to ten minutes (600,000 milliseconds). This is just enough time that they'll ignore it when it happens the first couple of times. Evil fun!
This is the final MakeCode:
What other kinds of movements, loops, and patterns can you create in order to increase the jiggly madness?!
If you enjoyed this project, take a look at the Foul Fowl project, a USB HID keystroke injection payload tool you can make with the Gemma M0 and CircuitPython!