Introduction: PC Mouse Emulator Using Arduino Uno and Sensors.
In this Instructable, we are going to build a prototype of Mouse emulator.The mouse emulator is a device that can be used when your mouse is not functioning properly.
Sensors are used for controlling the mouse movements.The project consists of one ultrasonic sensor, Three Infrared sensors, and processing language window for controlling the movements.The Software replicates the basic mouse movements such as click, left, right movements and scrolling.
The Arduino Leonardo board consist of processing chip so we don't require software and processing code to control the mouse movements.Once the software is run, then it can't be controlled by the normal mouse.
Step 1: Materials Required
1. Two IR sensors
2. Ultrasonic sensor
4.Arduino UNO 3
5. Arduino IDE and processing software.
7. Male to female jumper wires
Step 2: Introduction to Sensors
1. Ultrasonic sensor
An Ultrasonic sensor is a device that can measure the distance to an object by using sound waves.
It measures distance by sending out a sound wave at a specific frequency and listening for that sound wave to bounce back.
By recording the elapsed time between the sound wave being generated and the sound wave bouncing back, it is possible to calculate the distance between the sonar sensor and the object.
Distance=speed of light(constant)* time(calculated by sensor)
2. IR sensors
An Infrared sensor is a device that can an electronic instrument which is used to sense certain characteristics of its surroundings by either emitting and/or detecting infrared radiation.
It can be used to detect any object up to some distance.
The potentiometer inbuilt within sensor module board enables us to change the sensitivity of the device.
Step 3: Interfacing of Sensors With Arduino UNO
Steps that needed to be taken consider in mind while interfacing:
Ultrasonic sensor: Trig pin is the pin that is used to send out sound waves so it is an output state and echo pin receives the sound wave reflected from the object so it should be at input state with respect to microcontroller while defining the pin configuration. IC chips that are there in ultrasonic sensor modules calculate the time.
It is an analog data so it should be interfaced with analog pins of the microcontroller.
IR sensor: The pin that is there in IR sensor indicates either 1 or 0 depending upon whether the object is detected or not.If the IR receiver is receiving the rays, then higher logic will be there.
It is a digital data so it should be interfaced with digital pins of the microcontroller.
Setting up the whole circuit:
1. Connect 5v and GND from Arduino to power rails of the breadboard.The power to sensors will be given from power rails.
2. Now connect IR sensors "OUT" pin with 4,5 and 10 pins of Arduino.
3. Connect A0 pin of Arduino with ultrasonic sensor echo pin
4. Connect A1 pin of Arduino with ultrasonic sensor trig pin.
5.Connect laptop from Arduino using a USB cable.The maximum current that can be delivered by the Arduino through VCC pin is 200 ma so it will easily drive out the sensors.
6.Make sure that ground and VCC pins of the sensor are connected properly with the power rails of the breadboard.
Step 4: Interfacing of Arduino Processing Language
1.The processing software serial communicates with the Arduino through UART port.Make sure that one port is activated at the only time then only data communication can take place. The processing is open source software and can be downloaded easily from the internet.
2.The backend of the processing software is based on java language.
3. The open source robot library is used to emulate the mouse.
Link to download:https://processing.org/download/
Step 5: Setting Up the Java Program
Lets first set up the java program.Please ensure that you have updated all the processing libraries before running the code.
The robot library helps us to emulate the mouse and we can decide the how much the mouse pointer should move.
Make sure that your port is not busy while collecting data from the sensors. The program creates an interface between UART port and processing software which helps us to collect data from sensor and move mouse according.
Step 6: Setting Up the Arduino Code
Upload the code that is written to the Arduino board.
Make sure processing IDE is not running at that point in time.
Step 7: Troubleshooting
Getting the Java program to work may be difficult. I've got some tips if you're stuck:
-Change the "COM4" string in the PORT_NAMES to the port your Arduino Uno is connected to. (I changed to COM4 from the default COM3 in my Java program)
-Reset the Java Virtual Machine in your IDE. Maybe even reset the program before using the mouse the first time.
-Click "Rebuild Package" or your IDEs equivalent
Step 8: Conclusion
-It can be also used for disabled people by upgrading into a voice-controlled mouse.
-So the movement of the mouse will be controlled by our by the voice which can be used for blind persons or people who are having disabilities.
-The upgrading to the project involves controlling the mouse movement with fingers using accelerometer, voice control mouse.
Ultimately, the easiest solution is to use an Arduino Leonard or Mini that can function as a system device for mouse inputs, but I found it fun to make the Uno function in a way it was not designed.
Feel free to comment and ask doubts
We have a be nice policy.
Please be positive and constructive.