{"id":144578,"date":"2024-08-19T13:05:15","date_gmt":"2024-08-19T07:35:15","guid":{"rendered":"https:\/\/www.electronicsforu.com\/?p=144578"},"modified":"2024-08-19T13:13:37","modified_gmt":"2024-08-19T07:43:37","slug":"make-your-own-air-mouse","status":"publish","type":"post","link":"https:\/\/www.electronicsforu.com\/electronics-projects\/make-your-own-air-mouse","title":{"rendered":"Make Your Own Air Mouse"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"152\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2016\/12\/Screen-Shot-2016-12-24-at-15.19.33-e1644389186872.png\" alt=\"\" class=\"wp-image-28226\"\/><figcaption class=\"wp-element-caption\">Comment errors or corrections found for this circuit, and get the chance to win big!<\/figcaption><\/figure><\/div>\n\n\n<p>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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Additionally, left and right clicks can also be introduced by connecting the pins of the board with external buttons.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Components required:<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>S. no.<\/strong><\/td><td><strong>Name<\/strong><\/td><td><strong>Description<\/strong><\/td><td><strong>Number<\/strong><\/td><\/tr><tr><td>1.<\/td><td>IndusBoard Coin<\/td><td>3cm sized dev board<\/td><td>1<\/td><\/tr><tr><td>2.<\/td><td>Device (laptop)<\/td><td>A Laptop or other mouse-operated device is required.<\/td><td>1<\/td><\/tr><tr><td>3.<\/td><td>USB cable<\/td><td>Required to connect IndusBoard to the device.<\/td><td>1<\/td><\/tr><tr><td>4.<\/td><td>Push button<\/td><td>For left and right click.<\/td><td>2<\/td><\/tr><tr><td>5.<\/td><td>Jumper wires<\/td><td>To connect push buttons to the board.<\/td><td>3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Arduino Code<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code> #include &lt;LSM303AGR_ACC_Sensor.h&gt; \n#include &lt;Wire.h&gt; \n#include &lt;MPU6050.h&gt; \n#include \"USB.h\" \n#include \"USBHIDMouse.h\" \nUSBHIDMouse Mouse; \nMPU6050 mpu(); \n#if defined(ARDUINO_SAM_DUE) \n#define DEV_I2C Wire1 \/\/Define which I2C bus is used. Wire1 for the Arduino Due \n#define SerialPort Serial \n#else \n#define DEV_I2C Wire \/\/Or Wire \n#define SerialPort Serial \n#endif \n\/\/ Components. \nLSM303AGR_ACC_Sensor Acc(&amp;DEV_I2C); \n\/\/ sensors_event_t event; \n\/\/ mpu.getEvent(&amp;event); \n\/\/ float x = event.acceleration.x; \n\/\/ float y = event.acceleration.y; \nconst int leftButtonPin = 2; \/\/ Pin connected to the left button \nconst int rightButtonPin = 3; \/\/ Pin connected to the right button \nvoid setup() { \n\/\/ Led. \n\/\/ pinMode(13, OUTPUT); \n\/\/ Initialize serial for output. \nSerial.begin(115200); \nMouse.begin(); \nUSB.begin(); \nWire.begin(); \n\/\/ if (!mpu.begin()) { \/\/ Initialize MPU6050 \n\/\/ Serial.println(\"Failed to find MPU6050 chip\"); \n\/\/ while (1) { \n\/\/ delay(10); \n\/\/ } \n\/\/ } \n\/\/ Initialize I2C bus. \nDEV_I2C.begin(); \n\/\/ mpu.calcGyroOffsets(true); \/\/ Calibrate and print offsets \npinMode(leftButtonPin, INPUT_PULLUP); \npinMode(rightButtonPin, INPUT_PULLUP); \n\/\/ Initlialize components. \nAcc.begin(); \nAcc.Enable(); \n} \nvoid loop() { \n\/\/ Led blinking. \n\/\/ digitalWrite(13, HIGH); \n\/\/ delay(250); \n\/\/ digitalWrite(13, LOW); \n\/\/ delay(250); \n\/\/ Read accelerometer LSM303AGR. \nint32_t accelerometer&#91;3]; \nAcc.GetAxes(accelerometer); \n\/\/ mpu.update(); \/\/ Update MPU6050 data \n\/\/ \/\/ Read accelerometer values \nfloat accelX = accelerometer&#91;0]; \/\/ X-axis \nfloat accelY = accelerometer&#91;1]; \/\/ Y-axis \n\/\/ Map accelerometer values to mouse movements \nfloat mouseX = (float)(accelX * 0.01); \/\/ Adjust scaling factor as needed \nfloat mouseY = (float)(accelY * 0.01); \/\/ Adjust scaling factor as needed \nMouse.move(mouseX,mouseY); \nint leftButtonState = digitalRead(leftButtonPin); \nint rightButtonState = digitalRead(rightButtonPin); \nif (leftButtonState == LOW) { \/\/ Check if left button is pressed \nMouse.click(MOUSE_LEFT); \/\/ Send left click \ndelay(50); \/\/ Debounce delay \n} \nif (rightButtonState == LOW) { \/\/ Check if right button is pressed \nMouse.click(MOUSE_RIGHT); \/\/ Send right click \ndelay(50); \/\/ Debounce delay \n} \n\/\/ Output data. \n\/\/ SerialPort.print(\"| Acc&#91;mg]: \"); \n\/\/ SerialPort.print(accelerometer&#91;0]); \n\/\/ SerialPort.print(\" \"); \n\/\/ SerialPort.print(accelerometer&#91;1]); \n\/\/ SerialPort.print(\" \"); \n\/\/ SerialPort.print(accelerometer&#91;2]); \n\/\/ SerialPort.println(\" |\"); \n\/\/ for more smoothness \nif (abs(mouseX) &gt; 2 || abs(mouseY) &gt; 2) { \/\/ Adjust threshold as needed \nMouse.move(mouseX, mouseY); \n} \ndelay(20); \/\/ for smooth movement \n} <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Schematic and Real Implementation<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"565\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/U1-IndusBoard-1024x565.jpg\" alt=\"\" class=\"wp-image-144582\" style=\"width:438px;height:auto\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/U1-IndusBoard-1024x565.jpg 1024w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/U1-IndusBoard-500x276.jpg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/U1-IndusBoard-1536x847.jpg 1536w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/U1-IndusBoard-762x420.jpg 762w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/U1-IndusBoard-696x384.jpg 696w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/U1-IndusBoard.jpg 1605w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Schematic Diagram<\/figcaption><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"605\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/IndusBoard-and-breadboard.jpg\" alt=\"\" class=\"wp-image-144584\" style=\"width:436px;height:auto\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/IndusBoard-and-breadboard.jpg 927w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/IndusBoard-and-breadboard-500x326.jpg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/IndusBoard-and-breadboard-644x420.jpg 644w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2024\/07\/IndusBoard-and-breadboard-696x454.jpg 696w\" sizes=\"auto, (max-width: 927px) 100vw, 927px\" \/><figcaption class=\"wp-element-caption\">Author&#8217;s Prototype<\/figcaption><\/figure><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><em>Author(s): Manjeet Vishwakarma, \u00a0Abhay Verma and Satywanti Kundu are B.Tech ECE students at GJUS&amp;T HISAR<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":55758,"featured_media":144584,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,23,776,11851],"tags":[1985,1911,110],"class_list":{"0":"post-144578","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-electronics-projects","8":"category-hardware-diy","9":"category-prototypes","10":"category-super-innovative-projects","11":"tag-diy-projects","12":"tag-do-it-yourself","13":"tag-electronics-projects"},"_links":{"self":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/144578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/users\/55758"}],"replies":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/comments?post=144578"}],"version-history":[{"count":1,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/144578\/revisions"}],"predecessor-version":[{"id":146668,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/144578\/revisions\/146668"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/media\/144584"}],"wp:attachment":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/media?parent=144578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/categories?post=144578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/tags?post=144578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}