Piyush Garg
Published © GPL3+

Mini Micro Mouse! ($15)

A chocolate-bar-sized DIY micro-mouse that plugs into a computer, works instantly, and includes a built-in light.

IntermediateFull instructions provided5 hours14
Mini Micro Mouse! ($15)

Things used in this project

Hardware components

Modulo Joystick
Modulo Joystick
×1
Flora RGB Neopixel LEDs- Pack of 4
Adafruit Flora RGB Neopixel LEDs- Pack of 4
×1
Tactile Switch
×1
Arduino micro PRO (HID)
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
28 Gauge Wire
×1
Wooden Stick
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

Schematic

Connect All Electronic Components using the Schematic

Code

Mini Mouse Code

Arduino
Open File in Arduino IDE and Upload the code to the Arduino Pro Micro!
#include "Mouse.h"
#include "Keyboard.h"
#include <FastLED.h>

FASTLED_USING_NAMESPACE

#define Xpin A8
#define Ypin A9
#define Spin 7
#define LButton 16
#define RButton 14
#define LedPin 10
#define NUM_LEDS 1

#define LED_TYPE WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define BRIGHTNESS 100
#define FRAMES_PER_SECOND 120

int Hue;
int LeftButton;
int RightButton;
int JoyX;
int JoyY;

void setup() {

  FastLED.addLeds<LED_TYPE, LedPin, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);

  pinMode(Xpin, INPUT);
  pinMode(Ypin, INPUT);
  pinMode(LButton, INPUT_PULLUP);
  pinMode(RButton, INPUT_PULLUP);
  pinMode(Spin, INPUT_PULLUP);

  Serial.begin(9600);
  Mouse.begin();
  Keyboard.begin();
  delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:


  LeftButton = digitalRead(LButton);
  RightButton = digitalRead(RButton);
  JoyX = map(analogRead(Xpin), 0, 1023, 3, -4);
  JoyY = map(analogRead(Ypin), 0, 1023, 4, -4);

  fill_rainbow(leds, NUM_LEDS, Hue, 7);
  EVERY_N_MILLISECONDS(15) {
    Hue++;
  }
  FastLED.show();

  Serial.print("X:");
  Serial.print(JoyX);
  Serial.print("  Y:");
  Serial.print(JoyY);
  Serial.print("  S:");
  Serial.print(digitalRead(Spin));
  Serial.print("  LeftButton:");
  Serial.print(LeftButton);
  Serial.print("  RightButton:");
  Serial.println(RightButton);


  if (LeftButton == 0 && digitalRead(Spin) == 1) {
    Mouse.press(MOUSE_LEFT);

  } else if (LeftButton == 0 && digitalRead(Spin) == 0) {
    Keyboard.press(218);
    delay(10);
  } else {
    Mouse.release(MOUSE_LEFT);
    Keyboard.releaseAll();
  }
  if (RightButton == 0 && digitalRead(Spin) == 1) {
    Mouse.press(MOUSE_RIGHT);
  } else if (RightButton == 0 && digitalRead(Spin) == 0) {
    Keyboard.press(217);
    delay(10);
  } else {
    Mouse.release(MOUSE_RIGHT);
    Keyboard.releaseAll();
  }

  Mouse.move(JoyX, JoyY);
}

Credits

Piyush Garg
1 project • 0 followers
Hi! My name is Piyush, exploring electronics while making cool and intresting projects!

Comments