AIR Mouse is also called gesture-controlled mouse and it works based on hand gesture. In this project an accelerometer is used for measuring the tilt of hand in X and Y direction and moves the cursor according the tilt.
In the project two types of circuit are used, one is the transmitter circuit and other is the receiver circuit. Transmitter circuit makes use of MPU6050 series of accelerometer, which is connected to Arduino through I2C communication. The data is transferred to receiver Circuit using RF module, ASK433. Two switches are also used in transmitter circuit to work as Left Click and Right Click.
In the receiver side an Arduino Leonardo is used. The purpose of using Arduino Leonardo is that it supports HID (Human Interface Device). HID allows us to control the mouse and Keyboard of our PC or Laptop.
Components
Component | Specification | Quantity |
---|---|---|
Arduino | Leonardo | 1 |
Arduino | Nano | 1 |
Accelerometer | MPU6050 | 1 |
RF Module | ASK433 | 1 |
Switch | Momentary | 2 |
Switch | DPDT | 3 |
Resistance | 10K | 2 |
Battery | 9 Volt | 1 |
Battery Holder | 1 | |
USB Cable | 1 |
Circuit
In the project two circuits are used, one is the transmitter circuit and other is the receiver Circuit.
Transmitter Circuit
The transmitter circuit is placed in our hand. In this circuit, Arduino Nano is used which receives the data from accelerometer through I2C communication. MPU6050 is used in the transmitter circuit, which is accelerometer and supports I2C communication. SCL and SDA pins or accelerometer (MPU 6050) are connected to SCL and SDA pin of Arduino Nano, where SCL is A5 and SDA is A4 pins of Arduino. MPU 6050 have an INT pin, which is connected to interrupt (INT0) pin of Arduino that is D2.
Now data of accelerometer is transferred to receiver circuit using RF communication. For RF communication RF transmitter is used in transmitter side. Data pin of RF transmitter is connected to D4 pin of Arduino. An antenna is connected to ANT pin of RF transmitter. Antenna is nothing but only a 15 cm long single core wire.
Two switches are connected to D11 and D13 of Arduino that are Left Click and Right Click. This whole circuit is powered by 9-volt battery which is connected to Vin pin of Arduino through a switch.
If you are good in PCB Etching please use circuit provided below to build the project.
If you wish to build the circuit on universal PCB (ZERO PCB) or breadboard, use the design provided below.
Receiver Circuit
In the receiver side, two major components used are the Arduino Leonardo and RF Receiver. Two switches are used for Enable/Disable the mouse and on/off the RF communication.
In the receiver circuit data pin of RF Receiver is connected to Interrupt pin (INT1) of Arduino, that is D2 pin.
A switch is used in the power line of RF Receiver, which is used for ON/OFF of the RF Receiver. Another switch is also connected to D4 pin of Arduino that is used to Enable/Disable the mouse. Arduino Leonardo is connected to PC through standard USB cable.
Circuit and PCB schematic are shown below.
You can order these PCB’s through PCBWay (we have designed them according to rules of PCBway).
Working
In the transmitter side an Arduino Nano is used as the controlling unit. The accelerometer is connected to Arduino through I2C communication that measures the gravitational acceleration in X, Y and Z direction, but we need only values in two axis so we are using values of X and Y. Two switches are also connected to Arduino; they are used for Left and Right click. Arduino measures all the values, now we have four values
- Acceleration in X direction
- Acceleration in Y direction
- Status of Right click
- Status of left click
All the values are merged into an integer of four digits, where each digit shows each value.
In the receiver side, Arduino receives the data (integer) from transmitter and breaks into four values. Arduino Leonardo supports HID (Human Interface Device) so it moves the cursor according to values of X and Y.
Code
In this project two Arduino are used one is in transmitter side and other is in receiver side.
Transmitter Code
Download Transmitter Section – Program/Code
In the transmitter side three header files are used and you can download the libraries from the link
- h : Already Attached
- h : For MPU6050 Accelerometer : https://github.com/jarzebski/Arduino-MPU6050
- h : For RF transmitter and receiver module : https://github.com/sui77/rc-switch
“RCSwitch” is declared in line 5 and MPU6050 is declared in line 7. Two integers are declared for Left Click and Right click.
In the “void setup()” “serial.begin(115200)” is used for serial monitor. From line 16 to 20 “mpu6050” is checked, it helps for checking the wiring. After it a “checkSettings()” function is used for checking the setting of “MPU6050”. After that “mySwitch.enableTransmit(4)” is used for Enable the transmitter (RF transmitter module) which is connected to pin D4 of Arduino. At the end “pinMode” function is used for declaring Left Click and Right as input.
A “void cleckSetting()” is declared, it is used for checking the setting of “MPU6050”. This function is very long and complicated so we does not discuss this portion.
In the “void loop()” gravitational acceleration (normalized acceleration) is read from accelerometer. In line 72 and 73 values of X and Y is saved in integers that are processed values.
In the line 75 and line 76 status of left and Right Click is read and saved in integers. Now all the integers are merged in line 78 and saved in an integer and data is transmitted in line 80 over RF module.
Receiver Code
Download Receiver Section – Program/Code
At the staring of code two header files are used, first is used for the RF module and other (Mouse.h) is used for computer mouse.
In the line 4 “RCSwitch” is named as “mySwitch”. Some integers are declared in line 6 where “rvalue” is used for received data and “a”, “b”, “c” and “d” are the four values after breaking the “rvalue”. Two floats are also declared by name “xReading” and “yReading”.
In the “void setup()” “mySwitch.enableReceived” is used for enable the receiver. After it “mouse.begin” is used for starting the mouse. “pinMode“ is used for declaring the pin D5 as input.
In the “void loop()” an “if” condition is used, process come in loop when data is available over RF communication. Now received data is assigned in an integer “rvalue”. In line 23 to 26 received data (rvalue) is divided into four integers “a”, “b”, “c” and “d”. Where “c” and “d” are the value of acceleration in x and y direction, “a” and “b” are the status of left and right click.
From line 28 to line 44 values of “xReading” and “yReading” are declared according to values of “c” and “d”. In the line 46 RF communication is reset.
From line 49 to line 51 cursor is moved according to values of “xReading” and “yReading”, it will works when switch (connected to pin D4) is LOW. At the end left and right click is pressed according to values of “a” and “b”.
3 Comments
sir also i have problem in the transmitter code (class MPU6050 have no member begin ) plz help me
Reply
Leave a Repl
Sir I am currently working on this project. There are many arduino leonardo available in the online like REES52 Arduino Leonardo R3 , KitsGuru KG203 Leonardo R3 with USB Cable Module Arduino Compatible , xcluma Atmega32U4 5V/16M Mini Leonardo Pro Micro Arduino Compatible , Leonardo R3 ATmega32U4 Development Board With USB Cable For Arduino. So please tell me which arduino leonardo I should buy.
code is working properly?
i am facing problem in clicking can u help me?