Friday, November 8, 2024

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages

Make Your Own Air Mouse

Comment errors or corrections found for this circuit, and get the chance to win big!

Air mouse is a device used to control the mouse of a device such as a computer, mobile, smart TVetc. In this project, the air mouse is made using an IndusBoard coin device.

IndusBoard Coin has various built-in sensors such as accelerometer, magnetometer, temperature sensor etc. For the air mouse, an accelerometer is used. This sensor detects the position of the board which is implemented to make an air mouse by detecting the change in output readings.

Additionally, left and right clicks can also be introduced by connecting the pins of the board with external buttons.

- Advertisement -

Components required:

S. no.NameDescriptionNumber
1.IndusBoard Coin3cm sized dev board1
2.Device (laptop)A Laptop or other mouse-operated device is required.1
3.USB cableRequired to connect IndusBoard to the device.1
4.Push buttonFor left and right click.2
5.Jumper wiresTo connect push buttons to the board.3

Arduino Code

 #include <LSM303AGR_ACC_Sensor.h> 
#include <Wire.h> 
#include <MPU6050.h> 
#include "USB.h" 
#include "USBHIDMouse.h" 
USBHIDMouse Mouse; 
MPU6050 mpu(); 
#if defined(ARDUINO_SAM_DUE) 
#define DEV_I2C Wire1 //Define which I2C bus is used. Wire1 for the Arduino Due 
#define SerialPort Serial 
#else 
#define DEV_I2C Wire //Or Wire 
#define SerialPort Serial 
#endif 
// Components. 
LSM303AGR_ACC_Sensor Acc(&DEV_I2C); 
// sensors_event_t event; 
// mpu.getEvent(&event); 
// float x = event.acceleration.x; 
// float y = event.acceleration.y; 
const int leftButtonPin = 2; // Pin connected to the left button 
const int rightButtonPin = 3; // Pin connected to the right button 
void setup() { 
// Led. 
// pinMode(13, OUTPUT); 
// Initialize serial for output. 
Serial.begin(115200); 
Mouse.begin(); 
USB.begin(); 
Wire.begin(); 
// if (!mpu.begin()) { // Initialize MPU6050 
// Serial.println("Failed to find MPU6050 chip"); 
// while (1) { 
// delay(10); 
// } 
// } 
// Initialize I2C bus. 
DEV_I2C.begin(); 
// mpu.calcGyroOffsets(true); // Calibrate and print offsets 
pinMode(leftButtonPin, INPUT_PULLUP); 
pinMode(rightButtonPin, INPUT_PULLUP); 
// Initlialize components. 
Acc.begin(); 
Acc.Enable(); 
} 
void loop() { 
// Led blinking. 
// digitalWrite(13, HIGH); 
// delay(250); 
// digitalWrite(13, LOW); 
// delay(250); 
// Read accelerometer LSM303AGR. 
int32_t accelerometer[3]; 
Acc.GetAxes(accelerometer); 
// mpu.update(); // Update MPU6050 data 
// // Read accelerometer values 
float accelX = accelerometer[0]; // X-axis 
float accelY = accelerometer[1]; // Y-axis 
// Map accelerometer values to mouse movements 
float mouseX = (float)(accelX * 0.01); // Adjust scaling factor as needed 
float mouseY = (float)(accelY * 0.01); // Adjust scaling factor as needed 
Mouse.move(mouseX,mouseY); 
int leftButtonState = digitalRead(leftButtonPin); 
int rightButtonState = digitalRead(rightButtonPin); 
if (leftButtonState == LOW) { // Check if left button is pressed 
Mouse.click(MOUSE_LEFT); // Send left click 
delay(50); // Debounce delay 
} 
if (rightButtonState == LOW) { // Check if right button is pressed 
Mouse.click(MOUSE_RIGHT); // Send right click 
delay(50); // Debounce delay 
} 
// Output data. 
// SerialPort.print("| Acc[mg]: "); 
// SerialPort.print(accelerometer[0]); 
// SerialPort.print(" "); 
// SerialPort.print(accelerometer[1]); 
// SerialPort.print(" "); 
// SerialPort.print(accelerometer[2]); 
// SerialPort.println(" |"); 
// for more smoothness 
if (abs(mouseX) > 2 || abs(mouseY) > 2) { // Adjust threshold as needed 
Mouse.move(mouseX, mouseY); 
} 
delay(20); // for smooth movement 
} 

Schematic and Real Implementation

Schematic Diagram
Author’s Prototype

Author(s): Manjeet Vishwakarma,  Abhay Verma and Satywanti Kundu are B.Tech ECE students at GJUS&T HISAR

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Electronics News

Truly Innovative Electronics

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics

×