Hello. Today I want to share with you my, I will not be afraid of this word, achievement. I made an unusual mouse. This is a glove manipulator with 5 keys and an accelerometer. But first things first. First, a little background. ')
Project "Arduino"
It all started with what I learned about the Arduino project . “Arduino” is a hardware computing platform, the main components of which are a simple I / O board and the development environment in the language Processing / Wiring.Arduino can be used to create stand-alone interactive objects, as well as connect to software running on a computer (for example, Macromedia Flash, Processing, Max / MSP, Pure Data, SuperCollider). - Wikipedia tells us. I will explain a little. In fact, Arduino is a debugging board based on Atmel microcontrollers. Of course, it is much more expensive to buy an Arduino handkerchief than to buy a microcontroller (MK) and make the debug board yourself. But, in this project there is one big plus (I think, for this plus cost to pay) for big newbies in programming, which simplifies the process of writing programs and firmware MK - this is the Arduino IDE development environment, which includes the main libraries for working with peripheral devices MK. The development language Wiring is the same as C ++, only with libraries and functions for working with MCs (standard language functions, of course, are available).
So, it became interesting to me and I ordered a debug board based on the Atmega 1280 MK. And later, two small scarves based on the Atmega 328 MK. But this is not about that now. Having tried my hand at small “projects”, I decided to do something really interesting. And it was interesting to make a mouse - a glove.
Accelerometer and idea gloves
Without thinking, I ordered the accelerometer MMA7260QR2 . I thought to realize the movement of the mouse with the accelerometer. But after experimenting with him, I realized that the principle of his action would not allow exactly moving the mouse cursor. Therefore, I decided to use it for another function - it will replace the mouse clip, as well as some other actions. But then again, first things first.
The idea is this: on the glove there is a device with 5 buttons and an accelerometer. Data is transferred to the computer via a computer (my arduino board is connected via mini-usb, that is, the com port is implemented on the usb bus using an FTDI converter chip, so the computer sees the arduino as a com port), the program on the computer processes the received data and acts according to them. Moving the cursor, I decided to implement using a webcam and the LED on the glove, as with the accelerometer would not work. The freeware program FreeTrack allows you to do this. In short, this is a free software program that processes video from a webcam and receives data about the location of the LED (or several LEDs) in space. The program is designed for tracking in -avia, -auto simulators, shooters and so on. It has a “emulate mouse” function, which I used.
Visiting a local radio store, I bought 5 microswitches (“mikriki” by the people) from mice and began to develop a board (a platform that I would later put on a glove) on which to be located: 1) microcontroller board; 2) 5 "mikrikov"; 3) infrared LED; 4) accelerometer.
The accelerometer had to be “planted” on its own scarf (its dimensions are 6x6 mm), which I did with my dad. According to the accelerometer manual, I drew a board in the Sprint Layout program and according to the technology of manufacturing printed circuit boards at home (using a laser printer and iron) my father and I etched out this little handkerchief at home. After that, I connected it to the MK and experimented with it.
Arduino nano: description
Microcontroller ATmega328 Operating voltage (logic level) 5 V Input voltage (recommended) 7-12 V Input voltage (limit) 6-20 V Analog input 8 lines. ADC 10 bit Digital Inputs / Outputs 14 (6 of which can be used as PWM outputs) DC current through the input / output 40 mA Flash memory 32 Kb (ATmega328) with 2 Kb used for the bootloader Ram 2 Kb Eeprom 1 Kb Clock frequency 16 MHz Dimensions 1.85 cm x 4.2 cm
Board making - platforms
After I figured out how to work with an accelerometer, I clearly decided to make a conceived device. As a glove, I chose a sports bicycle glove. It is available and the view is quite good.
So, having everything you need to build the device, I set about developing a scheme for connecting all of this to the MC. Honestly, there is nothing complicated. But I had to redraw more than once the scheme. Having finished the scheme, I turned to dad for help in the manufacture of a printed circuit board all following the same technology of manufacturing printed circuit boards at home. After the board was made, I saw one mistake - the place for the accelerometer turned out not where it was planned, due to the fact that when drawing the circuit board did not take into account the overall dimensions of the buttons. Well, they learn from their mistakes.
Board soldering - platforms
This stage was the most difficult for me, since I do not solder well. But, after dad showed how to do it right and helped me, it became easier for me to solder. I will not describe this stage in detail. I will show only the result - a board with soldered MK and details on it. This is what the board looks like. MK firmware
I will describe only the principle of the firmware (programs in the memory MK). So, 5 keys, an accelerometer and a LED are connected to the MC. All I need is to receive data on the state of the buttons (pressed or not) and data from the accelerometer (which way it is tilted and how much it is tilted). All this happens in an infinite loop (this is the principle of the MC operation - to execute the program cyclically while it is on). Data is sent to the computer port.
I can say that having basic knowledge of the C ++ language and the principles of programming, it is easy to write the firmware. This is facilitated by the Arduino IDE development environment, thanks to which it is not necessary to read datasheets on the MK for hours and find out which register is responsible for which function of the MK. But this, of course, is also easy, and you need to know it at least for yourself, to know what you are dealing with. But arduino allows you to do a “quick start” without delving into the intricacies of MK programming, which I use.
The program “Mouse Track” to receive data from the glove
The principle of operation: in a separate stream, in the infinite loop, the necessary com port is polled. The program receives data from the glove (from MK) and performs the appropriate actions. For example, if the button1 is pressed, then this is reported via the com port of the program and it performs the action “button1 pressed”. If the button1 is released, the “button1 released” message is reported. I wrote the program on Delphi 7. I implemented the following: you can assign one of the 5 mouse actions (LMB, SCM, RMB, movie up, movie to them) or one of the 4 actions with the window (close, minimize, move, maximize / restore ). With the accelerometer the same situation - on the slopes to the right, left, forward, backward, you can assign the same functions. The accelerometer “dead zone” is also regulated. I measure the inclination of the accelerometer from 0% to 100%. So, the threshold of the accelerometer command on the slope can be adjusted. For example, the command will be executed if the threshold is set at 50%, that is, if the accelerometer is tilted by half. And so for each axis. Speaking of axes. In the accelerometer that I used, 3 of them are x, y, z. But I only used x and y.
In the “mouse emulation” tabs you can use the following functions: LMB, SCM, RMB, scroll the video up / down. The tabs “Action with a window” have the following functions: move the window, close the window, minimize the window, maximize / restore the window.
You can also use the "Hot Keys" gloves. That is, a combination of some keys to call the assigned program.
Design and appearance
Pressing the key with my fingers, I came up with the following - the finger is bent, pulls the wire, soldered (in my case set on silicone) to the button, and thus the button is pressed. Such a simple way. This is how it all looks.