Foam Board Enabled Mouse | |
This project uses a low-cost Trinket M0 board, foamboard, and momentary 7mm switches to create an enabled mouse for a computer or mobile device interaction. The code is built using the Maker MakeCode editor which supports easy drag and drop coding and flashing. | |
**This build is geared towards the nontechnical/ novice user and uses the MakeCode block-based programming language. | |
Qty | Item |
1 | |
1 | Foam Board |
5 | |
5 | |
5 | |
1 | Micro USB Cable (data) |
1 | |
1 | Masking or Duct Tape |
1 | Super Glue |
1 | Mini Zip Tie |
Soldering Iron and solder |
Wire- Unthreaded if available |
Wirecutter and stripper |
Flush Nose Cutter |
X-Acto Knife |
Awl |
Never soldered before? Check out this beginner-friendly how-to video from Adafruit.
Step #1: Cut and Paste the Layers | |
Paste the layer templates onto the foam board and cut them to size. Be sure to cut out the openings for the buttons in the middle and top layers indicated by a dotted line. | |
Step #2: Prepare the buttons | |
For each button, cut and strip one end of the jumper cable and solder the stripped end into the NO (Normally Open) pin on the switch. Repeat for all 5 switches | |
Step #3: Connect Button Ground and Board Ground Cables | ||
Strip both ends of 5 wires about 130mm long together and twist into a bundle. Solder the wires in place. | Cut a single wire about 50mm long, stripping both ends, and soldering one end into the GND pin. Solder the bundle and single wire together. | Insulate using either heat sink if available to electrical tape. |
Step #4: Solder the headers and ground cables to the board | |
Solder the angled header pins into the board for pins labelled 0, 1, 2, 3, 4. | |
Step #5: Insert the buttons into the middle layer | |
Insert the switches corresponding with the Up, Down, Right, and Left directions into the middle layer board. Thread the switch for the mouse click through the center slot. | |
Step #6: Connect Button Ground and Board Ground Cables | |||||||||||
Solder the 5 ground wires into the pin labled “C” on each switch. You may need to flip the board to determine the correct pin to use. | Attach the jumper wires to the corresponding pins on the board following the diagram on the base layer:
| ||||||||||
Step #7: Adhere the Trinket board and buttons to the base layer | |
Place the board onto the base layer and mark the location of mounting holes. Use an awl to pierce a hole in the inidicated locations Insert and tighten a zip tie through. Ensure the buckle is placed between the layers and not under the bottom layer. | Locate the area of the reset button on the board and pierce a hole over the button on the middle layer. |
Step #8: Navigate to the MakeCode Editor and load a new project | |
Navigate to maker.makecode.com Click on the “Adafruit Trinket M0” board and select “New Project” After the IDE loads, rename the project “Trinket Mouse”. Or any other desired name. | |
Step #9: Load the Mouse Library | |
From the blocks menu, select “+ extension”. Locate the “Mouse” library and allow time for the library to be added to your project. | |
Step #10: Determine Desired Mouse Functionality | |
Continuous MovementThis access method will move the cursor in the indicated direction while the switch is being pressed. | Stepped MovementThis access method will move the mouse cursor a set number of pixels each time the button is pressed. A repeated press is needed for the next movement. |
Step #11a: Continuous Movement Code | |
From the “Loops” menu, drag the “While Do” block and nest inside the “Forever” loop. From the “Input” menu, drag the “Touch button” and replace the “false” condition block. Using the drop down menu on the Touch condition, chance it to button D0. From the “Mouse” menu drag the mouse move block and nest it into the “while do” loop. Update the y coordinate to 2. | |
Step #11b: Stepped Movement Code | |||||||||||
From the “Input” menu drag the “on Click” block and select button D0 from the dropdown list. From the “Mouse” menu, drag the “mouse move x,y” block and place inside the “On Click” block. Set the x coordinate to 0 and y to 10. This will move the mouse cursor up 10 pixels on the screen. | |||||||||||
Continue to program the rest of the pins following the code in the image to the left:
| |||||||||||
Step #12: Flash the code onto the board | |
Click the download button at the bottom of the Makecode IDE. You should now have a Trinket Mouse.uf2 file in your default download location. | |
Connect the board to your computer using the USB cable. A new drive titled “TRINKETBOOT” should now be visible. **You may need to press the reset button on the board to enter bootloader mode. | |
Click and drag the .uf2 file into the TRINKETBOOT drive. That’s it! | |
Once the code is flashed, the BOOT drive should no longer be visible. Time to test the various buttons to ensure the cursor is traveling in the correct directions. Adjust your code or pin connections if needed. | |
Step #13: Adhere the board and buttons to the base layer | |
Insert the loose mouse click switch into the top layer. | Tape the parameter of the board in place securing the bottom and middle layers. |
Step #14: Adhere the board and buttons to the base layer | ||
Apply superglue to the level portion of each switch ensuring glue does not drip onto the button below. | Place the top layer over the buttons and hold in place. Be sure not to place too much pressure as to limit the movement of the lever. | Apply glue and adhere the click button. |
Step #15: Test it Out! | ||
Connect the adapted mouse to your desired computer using the USB cable. Navigate the cursor and click button as needed. Or test it on this website: Adapted Mouse Tester | ||
Modifications: | ||
To adjust the moved distance in stepped mode: | ||
Last edited on: Nov 27, 2021