3D Contactless Mouse (Interactive 3D Position Sensor)




Introduction: 3D Contactless Mouse (Interactive 3D Position Sensor)

About: I have a degree in engineering physics. I like to make crazy scientific experiments.

Recently, I have made this 3D contactless mouse, which I use to control (or to try to control) my computer cursor. You can see the functionalities in the video below :

All the computation is made on the arduino leonardo, which emulates a mouse. In fact, it's a very simple vision system that uses only five ultrasonic range sensors to make converge the robot towards the object and to lock its orientation on it by the primitive detection of the edges I've developped.

In this Instructable, I will show you how to build your own version of this amazing device!

Step 1: List of Materials

  • These 3D printed parts
  • A small screw and two bolts (I can't tell the type but the screw is about 1/8'' in diameter, 1'' in lenght)
  • A rotationnal bearing (I've made one with a small rod and a small roller taken in a cassette player)
  • Some counterweight (I use three 25 cents)
  • An Arduino Leonardo
  • Six micro servomotors 9g
  • Five ultrasonic range finder
  • A lot of connecting wires (15 female to male and 18 male to male, plus some breadboard wire)
  • A micro usb to usb A wire
  • An arduino protoshield with a mini breadboard
  • An external 5V DC power supply for the servos
  • A 555 timer
  • A LM386 amplifier
  • An electret microphone
  • Resistances (2X 4.7kΩ, 1X 10kΩ, 1X 100kΩ)
  • Capacitors (3X 10nF, 1X 1µF)

Tools :

  • A glue gun
  • A computer

Step 2: Glue the Parts

I'm using hot glue since it's sufficiently robust for the need, it works great with PLA and moreover, it can easily be completely removed if you've glued something wrong.

Ultrasonic range finders :

Put a little bit of glue on the crystal, then glue the support. Solidify the barrels. Glue a servo horn on the side.

Central section :

Glue the 4 servos in their appropriate casings. They should be glued to the frame in their middle. Tape or glue their wires in the backside. Glue the central ultrasonic range finder in the center.

Base :

Pass the servo wires in the hole of the support, then glue the servo to it. You can put a clamp to secure the robot to a table. Also, you can glue the arduino to it via a 3D printed support.

Mounting bracket :

Glue the two sides together with the little base. Attach the servo horn to the base servo, then glue the bottom of the mounting bracket to it. There is a hole to solidify this junction, don't hesitate to fill it with hot glue. Glue a servo to the square hole to the top of the bracket, gear towards the interior and in the upper section. Glue the 2 nuts in the top of the other bracket, insert the screw, glue the roller to the tip of it. Glue the little rod on the central frame. To mount the central frame, unscrew to make a little space, then insert the rod in the roller and screw until everything is secure. This part of the robot is a little bit fragile, you may have to repair it often. Finally, glue three 25 cents below the nuts (this is a counterweight of the servo).

Step 3: Connect the Servos and the Sensors and Build the Circuit

Connecting all the wires can get a bit messy (I talk by experience...). Use a good amount of methodology. Note that I use a one-data-pin configuration for the ultrasonic sensors. In the model I use, the Trigger and Echo are on separate pins, so I've put a little jumper.

Here are the listing of the pinout for the connection to the arduino :

2 : base servo (theta)

3 : Non-connected for interference reason

4 : up & left servo

5 : down & left servo

6 : down & right servo

7 : up & right servo

8 : up & left sensor

9 : down & left sensor

10 : down & right sensor

11 : up & right sensor

12 : middle sensor

A0 : tilt servo (phi)

A1 : Sound input

Connect the Vcc of the sensor to the 5V regulated by the arduino.

Important : Connect the Vcc of the servos to an external 5V supply (otherwise, your Arduino will suffer...)

Connect all the grounds together.

I've joined a picture of my breadboard along with schemas. It's a bit compact, you can see that the unused space on the shematic breadboard is in reality full of supply wires for all the servos and the sensors. As there is no supply rails on a mini breadboard, it's more difficult to understand the circuit and to troubleshoot. This is not a complex circuit, take your time and everything will go straightforward. The voltage divider before the LM386 can be replaced by a trimpot for a more accurate control on the sensibility of the microphone.

Step 4: Upload the Code

This is the code (echolocator3d.ino). I've commented it so it should be readable, but don't hesitate to communicate with me if something is unclear.

I've also made a short code for testing the servos. Run it and play with angle values to find flat initial positions (all the sensor must align in the central plane). Then put these values in the real program, in the "servo start angle" section.

The serial monitor is also useful for debugging.

Step 5: Familiarize With Controls

At this step, everything should work fine. The robot is most of the time capable to follow your hand. Here is the user guide for the interface with the mouse :

  • Stay between 10cm and 30cm of the robot : this is the range where scroll is not activated
  • Below 10cm, you will scroll down; over 30cm, you will scroll up.
  • The maximum distance where an object is detected is 45cm. Staying farther than that will trigger the scan mode and deactivate the mouse function (don't panic!)
  • The angular position relative to the center will determine the cursor movement. It's made to naturally mirror the movement (like a conventional mouse). Unlike a conventional mouse, a perpetual motion will result of a shift in position. If you want no cursor movements, return to the center. Moving near the center will lead to a precise, low speed displacement, whereas moving far (within the limits) will lead to a higher speed displacement. Note that in all cases it remains sufficiently slow to maintain a correct control of the cursor. As the sampling rate of the sensor is low (~17Hz), it may present a little latency (it's also due to the little torque the tiny servos can output). It's not an interface made for rapid interaction and the good old mouse is better for achieving the same task.
  • A snap of finger will make a left click (or maybe two (double-click), or maybe not). The reliability is not 100% for many reasons (the correct sensibility is very hard to achieve, the time for executing a loop may vary, etc.), but admit that this trick is pretty cool!
Sensors Contest

Participated in the
Sensors Contest

Be the First to Share


    • Organization Challenge

      Organization Challenge
    • Clocks Contest

      Clocks Contest
    • Baking Contest

      Baking Contest



    5 years ago

    Its showing
    Exit status 1
    Error compiling for board arduino/genuino uno.


    6 years ago

    how did u calliberate the position of the sensors and their angles at which they are placed?


    Reply 6 years ago

    Hi, I have made a different arduino program only for calibration, it's called test_servos.ino, see above. So it's really basic and not optimal, it could be easily improved, what I do is to flash the robot with this code, check the position of each of the sensors, remove them and replace them by hand if they're really too far from the plane, then I play with the angle values in the code, re-upload it, check the position, and iterate like this a couple of time. When I'm satisfied with the result, I copy-paste the values of all these angles in the real program, I don't remember how I've called these initial values but you will find it easily, it's at the beginning of the code. Once it's calibrated it can stay calibrated a long time if everything stays mechanically in place, but often what happens is that a sensor drops... But it's not so critical to recalibrate it each time it happens, it can tolerate a good amount of error before going totally crazy.


    this will be more awesome if the fluidity of using this is high. this has a potential for commercial use, but still this is awesome.


    8 years ago on Introduction

    is it possible for it to run on a different board??


    Reply 8 years ago on Introduction

    It's possible to run it on all the boards that support the "mouse"
    functions (Leonardo, Micro, Due). It will be compatible with all the
    arduino boards if you comment the lines where this set of functions


    8 years ago on Introduction

    Nice job! It took a big range of skills to make that.


    8 years ago on Introduction

    Cool project! And what makes it even better is the use of phi and theta in the code! =)


    8 years ago on Introduction

    I'm a little unclear on why the ultrasonic sensors are on servos. Is it just to increase the size of the sensing space?


    Reply 8 years ago on Introduction

    It's for increasing the responsiveness. The sensors orient themselves to follow the shape of the object.