# Phantom Mouse Jiggler

## Overview

https://youtu.be/hdfkuC3CgSQ

![](https://cdn-learn.adafruit.com/assets/assets/000/051/921/medium800/adafruit_gemma_P3100058_2k.jpg?1520811239)

Ever had your cursor move a little bit while you weren't even touching the mouse? Freaky! This MakeCode program will turn your Gemma M0 into a Phantom Mouse Jiggler. When plugged in to a computer, it will wait patiently, and then occasionally take over the mouse cursor from the user and move it around back and forth. Maddening!

Danger: 

One very powerful feature of the Gemma M0 (and other ATSAMD21 ARM Cortex M0-based microcontrollers) is its ability to appear as a keyboard or mouse when plugged into a computer’s USB port.

The Gemma M0 can pretend to be a USB mouse, so we'll take a look at how to program it with MakeCode to wait dormant for long periods of time, and then jiggle the cursor for a few seconds!

Info: 

## Parts

All you'll need is a Gemma M0 and a short USB cable to program and then deploy this prank!

### Part: Gemma M0
quantity: 1
Powerful yet small microcontroller
[Gemma M0](https://www.adafruit.com/product/3501)

### Part: USB Cable
quantity: 1
A/Micro B - 6"
[USB Cable](https://www.adafruit.com/product/898)

# Phantom Mouse Jiggler

## Code the Phantom Mouse Jiggler

## Create a MakeCode Project

First, head to the [Maker.MakeCode](https://maker.makecode.com/) 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.&nbsp;

If you're building this project with a Circuit Playground Express, go to the 'regular' [MakeCode](https://makecode.adafruit.com/) website, and just skip the first step where you pick which board to use.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/904/medium800/adafruit_gemma_gemmaM0_UV_Reader01.jpg?1520810812)

Click on the Gemma M0 image to select it.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/905/medium800/adafruit_gemma_gemmaM0_UV_Reader02.jpg?1520810825)

Now, click the&nbsp; **New Project** &nbsp;button to create a new program using the Gemma M0.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/906/medium800/adafruit_gemma_gemmaM0_UV_Reader03.jpg?1520810836)

## Building Blocks

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/907/medium800/adafruit_gemma_gemmaM0_UV_Reader04.jpg?1520810846)

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.

## Extension

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&nbsp; **Advanced&nbsp;** item in the category palette, then click on&nbsp; **Extensions.**

![](https://cdn-learn.adafruit.com/assets/assets/000/051/908/medium800/adafruit_gemma_m0_-_MakeCode_Maker_Boards__Cortex_class_.jpg?1520810880)

Next, click on the&nbsp; **mouse&nbsp;** extension. As it says, this will add blocks capable of USB mouse emulation over HID.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/909/medium800/adafruit_gemma_m0_-_MakeCode_Maker_Boards__Cortex_class__2.jpg?1520810895)

## Mouse Blocks

This will add a&nbsp; **mouse&nbsp;** category to the palette -- click on it, then drag to the canvas a&nbsp; **mouse move x 0 y 0&nbsp;** block.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/910/medium800/adafruit_gemma_m0_-_MakeCode_Maker_Boards__Cortex_class__3.jpg?1520810906)

![](https://cdn-learn.adafruit.com/assets/assets/000/051/911/medium800/adafruit_gemma_m0_-_MakeCode_Maker_Boards__Cortex_class__4.jpg?1520810914)

Info: 

## Move Forever

Place the&nbsp; **mouse move&nbsp;** block inside the&nbsp; **forever&nbsp;** block. Change the values from `0,0` to `7, -3`.

Then, from the&nbsp; **loop&nbsp;** category, add a&nbsp; **pause 500&nbsp;** block as shown, and change the value to `5000` milliseconds. This will cause the cursor to move every five seconds.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/912/medium800/adafruit_gemma_m0_-_MakeCode_Maker_Boards__Cortex_class__5.jpg?1520810923)

![](https://cdn-learn.adafruit.com/assets/assets/000/051/913/medium800/adafruit_gemma_m0_-_MakeCode_Maker_Boards__Cortex_class__6.jpg?1520810935)

![](https://cdn-learn.adafruit.com/assets/assets/000/051/914/medium800/adafruit_gemma_m0_-_MakeCode_Maker_Boards__Cortex_class__7.jpg?1520810945)

## Testing

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/915/medium800/adafruit_gemma_Mouse_Jiggler_-_MakeCode_Maker_Boards__Cortex_class_.jpg?1520810964)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/916/medium800/adafruit_gemma_Downloads.jpg?1520810977)

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.

## Wiggle Wiggle

From the&nbsp; **loops&nbsp;** category, drag a&nbsp; **repeat 4 times&nbsp;** block into the&nbsp; **forever&nbsp;** block.

![](https://cdn-learn.adafruit.com/assets/assets/000/051/917/medium800/adafruit_gemma_Mouse_Jiggler_-_MakeCode_Maker_Boards__Cortex_class__2.jpg?1520810988)

Duplicate your existing&nbsp; **pause&nbsp;** and&nbsp; **mouse move&nbsp;** blocks and arrange them as shown. Adjust the values as follows, from top to bottom:

- `pause 5000`
- `repeat 7 times`
- `mouse move x 22 y -9`
- `pause 100`
- `mouse move x -22 y 9`
- `pause 100`

![](https://cdn-learn.adafruit.com/assets/assets/000/051/918/medium800/adafruit_gemma_Mouse_Jiggler_-_MakeCode_Maker_Boards__Cortex_class__3.jpg?1520810998)

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!

## Long Delay

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!

![](https://cdn-learn.adafruit.com/assets/assets/000/051/919/medium800/adafruit_gemma_Mouse_Jiggler_-_MakeCode_Maker_Boards__Cortex_class__4.jpg?1520811007)

This is the final MakeCode:

https://makecode.com/_FM7HJWLfveD2

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!

![](https://cdn-learn.adafruit.com/assets/assets/000/051/923/medium800/adafruit_gemma_hackedFF.jpg?1520811933)


## Featured Products

### Adafruit GEMMA M0 - Miniature wearable electronic platform

[Adafruit GEMMA M0 - Miniature wearable electronic platform](https://www.adafruit.com/product/3501)
The **Adafruit Gemma M0** is a super small microcontroller board, with just enough built-in to create many simple projects. It may look small and cute: round, about the size of a quarter, with friendly alligator-clip sew pads. But do not be fooled! The Gemma M0 is incredibly...

In Stock
[Buy Now](https://www.adafruit.com/product/3501)
[Related Guides to the Product](https://learn.adafruit.com/products/3501/guides)
### USB cable - 6" A/MicroB

[USB cable - 6" A/MicroB](https://www.adafruit.com/product/898)
This here is your standard A-microB USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your NETduino, Arduino Leonardo, Raspberry Pi (among other things).  
  
Approximately 6.5" long from end to end, its a little more compact than our classic 3' long cable  
<br...></br...>

In Stock
[Buy Now](https://www.adafruit.com/product/898)
[Related Guides to the Product](https://learn.adafruit.com/products/898/guides)

## Related Guides

- [3D Printed LED Fire Horns](https://learn.adafruit.com/3d-printed-led-fire-horns.md)
- [Sensor Plotting with Mu and CircuitPython](https://learn.adafruit.com/sensor-plotting-with-mu-and-circuitpython.md)
- [Using MCP23008 & MCP23017 with CircuitPython](https://learn.adafruit.com/using-mcp23008-mcp23017-with-circuitpython.md)
- [CircuitPython Hardware: Charlieplex LED Matrix](https://learn.adafruit.com/micropython-hardware-charlieplex-led-matrix.md)
- [Spy Theme Playback Device](https://learn.adafruit.com/spy-theme-playback-device.md)
- [Using Piezo Buzzers with CircuitPython & Arduino](https://learn.adafruit.com/using-piezo-buzzers-with-circuitpython-arduino.md)
- [AM Radio Morse Code Paddle](https://learn.adafruit.com/am-radio-morse-code-paddle.md)
- [Logan’s Run Hand Jewel LED](https://learn.adafruit.com/led-in-you-hand-logans-run-life-clock.md)
- [NeoPixel Basketball Hoop](https://learn.adafruit.com/neopixel-mini-basketball-hoop.md)
- [Building CircuitPython](https://learn.adafruit.com/building-circuitpython.md)
- [Creating and sharing a CircuitPython library](https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library.md)
- [MakeCode Maker](https://learn.adafruit.com/makecode-maker.md)
- [Disco Band Camp Jacket](https://learn.adafruit.com/disco-band-camp-jacket.md)
- [Hanukkah MakeCode Menorah Sweater](https://learn.adafruit.com/hanukkah-menorah-sweater.md)
- [The Foul Fowl -- Keystroke Injection Attack Tool with Gemma M0](https://learn.adafruit.com/the-foul-fowl-keyboard-injection-payload-gemma-m0.md)
