Air Mouse Gun.

Markeno

Member
Jul 19, 2019
98
40
18
hobbytronics.home.blog
I have been working on an air mouse based arcade gun. I have missed playing Duck Hunt. I thought that it wasn't practical initially as I didn't know about the Air Mouse, and that the emulators can use a mouse for games such as Duck Hunt that were made to use a Light Gun with a CRT TV. I fairly recently purchased a 3d printer, and then finding out about the concept of an Air Mouse for the use has given me the opportunity to come up with something workable. I had been aware of that certain Arduino boards, mainly the Pro Micro can act as a USB Mouse (and/or Keyboard). There was a recent video from Element 14 where they converted a Nintendo Light Gun to an Air Mouse. I didn't want to take apart a Light Gun, which I haven't had one for awhile anyways, so I have been looking out for a usable 3d model. I wasn't sure how well this thing would work out, and I wanted something that was easy to 3d print, so I have been looking for something that was easy to print. It was intended for another use, so I had to remove some items, hollow out for the electronics, split it, right it for screws, work out support and mounting for the trigger and a secondary button.

The programming I am using for the Pro Micro is based on a simple example program I found. It was nice that it was quite simple, so it didn't take too much to understand what was happening. It was using several delays though, which was bad for keeping the cursor tracking a target when firing. I did find the origional seemed to be fairly workable as a mouse, while my changes made it more sensitive and difficult to click and doubleclick something easily. The difference being, when it registered a click, the mouse would "freeze" in that position, press the button pause then release the button. Now the cursor keeps moving, making it do a "hold and drag" when using it as a traditional mouse. There seem to be some timing things with the game selection and the "mouse" buttons. While the program is simple enough, each accelerometer can be a little different. The program needs some calibration to keep the cursor from drifting when it is not moving. I have 2 currently, the first one I tested with on a breadboard then the second one which I built the prototype gun with.

The Air Mouse Gun is certainly not the same as the original Light Gun. When in "Mouse" mode, there is a cursor on the screen that shows where you are pointing. The Air Mouse has no way of knowing what it is pointing at, it drifts as you use it so you can't really aim by using the gun. The motion is from the x and y axis acceleration, the faster you move it, the faster the cursor moves, if it hits the edge of the screen it stops moving, but obviously the gun has now gone out of line. If I want to keep it relatively centered, then I can push it into a corner to realign the gun so it is mostly pointed correctly at the screen between rounds.

I was thinking there is also a gyroscope built into the module I am using. I would think there should be a be a way to set the gyro relative to a "set" orientation and use that, making max values. Distance from the screen would probably need to be within a certain relative distance to have it calibrated well to it. While that sounds possible, and maybe there is code out there doing that with an Air Mouse, it is beyond me at this point. There is the positive that it is very easy to reprogram, and if I came across a way to do it with the Gyro, I should just have to update the programming. Still to "set" the orientation I would think it would be easiest to add another button, although it could be set to hold the second button down 5 seconds or something or some combination of the two and a length of time.

I have to make some changes yet, both to the code and the model. I'll see how that goes, I was hoping to finish it up tomorrow, but all the stuff going on I am doubtful now.

I was wondering does anyone here have experience on making an Air Mouse with an Arduino Pro Micro or similar that may be able to point me in a direction with the Gyro in some way to keep the cursor tracking more to the tip of the gun?

There are more advanced options, I guess there are some expensive options. There is the option to get a sensor bar very much like the Wii used that works with a Wii Remote, that can then be put in one of the gun holders, which I have around. My cabinet isn't setup in a way for the light bar, I don't think I care to do that, I don't like how the Wii Remote looks in the gun holders either. I would guess there still would be the requirement to have the onscreen cursor, although maybe not.
 

Markeno

Member
Jul 19, 2019
98
40
18
hobbytronics.home.blog
I got it working pretty well over the weekend. I managed to get some free time to revise a few things on the model setup. The blue gun is the original prototype. The Grey one is the revised version of the model with a few improvements, but still a bit incomplete. I tried some metal threaded inserts, but I didn't know what size to make the holes to accept them properly. They need resized. I need to improve things around the usb cord area, hopefully to get it to take a standard micro usb cable. As it is I need to make up a cable with just the minimum micro usb connector soldered onto the wire and no casing. They are rather simple devices overall, being just the Arduino Pro Micro and the GY-521/MPU-6050 module. There are the two buttons with some pull down resistors, yes typically something like a 10k is used, but I used some old 22k resistors I had laying around. I ended up and added a green LED in the tip that lights while the trigger button (Left Mouse Button) is being pressed. If I find I don't like it, I can just update the programming to not light the LED as they remain easy to reprogram. I have tested the Grey one, but I haven't made the cord for it yet. The little cut out "box" in the cord area was intended for a zip tie, it is a bit too small though, it is one of those bits that still needs some refining on the model. They are sturdy enough, they don't feel bad to hold. The model is one I found on Thingiverse, that I found could be modified to work. It has some style to it, it is very easy to print, although it took quite a few changes to switch it from the original intended use to this one properly. My son keeps wanting me to make a prettier version that is rounded. I was looking if I got it where I wanted for the USB cable area, that I would see if I could post the revision on Thingiverse.

IMG_20200316_214535404.jpg
The button are very tightly fitted, I had to do a little cleanup on the edges around them, the bases are held in place by the supports there. They can't move around very much. If I get real picky about it, the MPU-6050 LED as well as the ones on the Pro Micro are visible though the seams of the shell as the edges don't overlap.
IMG_20200316_214449717.jpg

Here is the other side, they are rather similar except the inserts compared to the self tappers. The openings for the "buttons" didn't yet exist in the Blue one when it was printed, so they were cut in after the fact. Some of the original openings in the model were also not yet closed so they have some pieces fitted differently although they an't the easiest to see in the pictures. The usb cord is a bit better aligned to the center, but still not right, the opening doesn't properly accept the ziptie in that little box, and I think I just in general need to work on those bits.
IMG_20200316_214421724.jpgIMG_20200316_222025179.jpg
With the Blue one I wasn't too worried about it being mistaken for a real gun, I guess the cord helps. The grey one would be easier to mistake I expect, it will be getting an orange tip, maybe a little on the blue one's front too at some point.
 
May 22, 2019
650
312
63
I've had a couple of different gyro based mice, including my favorite, the now discontinued Gyration media center remote.

1584552777273.pngNotice the really wide button in the middle, right above the green button. That's actually a mouse left/right click and a Move button.

The Move button acts like a lock... when the button is pressed and held, the cursor moves. When it's released, the cursor stops moving. If the user double-clicks the move button, the cursor moves.

This allows you to pick up the remote, do a quick movement to a control on screen, then stop moving so you can click the mouse buttons without jerking the cursor off of the control. This is the important part, as clicking the buttons tends to cause some movement.

In the case of your gun, you might put the Move button on the top of the grip, so the user could center the gun on the screen, then click the button to enable mouse control. When he's done, he could click the button again to disable it.
 

Markeno

Member
Jul 19, 2019
98
40
18
hobbytronics.home.blog
Not a bad idea for helping make it a usable air mouse. As a "light gun" substitute it works well as is. The only problem with a button to freeze the cursor, is the pressing it will have the same issues moving the cursor off target.. Maybe if it only let the cursor move while holding it down it could work? Still I wouldn't want to always be holding it down that may cause some hand strain. The way the code worked originally was that when the button press was registered, it froze motion for about .25 Seconds and pressed and released the mouse button. So holding the button down for more than .25 Seconds caused it to click again. That made it work well enough as a single click mouse, I don't know if it was fast enough for double clicking. It made it so you couldn't Drag and Drop, or do a Drag to Select anything.

Still it turns out to be quite a simple project, I think the original code being around 45 lines. Two primary parts, a few buttons and resistors. I really liked putting it together and hope to get the cord done for the second one this weekend. Work doesn't let me take off just yet, but I'll probably end up with more free time shortly as things are going. Still I look forward to getting some time with the kids and not just working on hobby stuff of my own.

I would like to get it like the WiiMote where you could point it at the screen and calibrate the corners etc, but that is beyond the level of complexity I want to get into. There is a device that works like the Wii sensor bar that you can buy that lets you pair a WiiMote with it and use it as a light gun. I am not sure about the corner calibration. Still those Wiimote gun holders are rather bulky and don't at all look like the old Light Guns. There are so few games I know of that I might use such a thing with. The plus with the WiiMote sensor bar is that it can recognize two independent guns for Two Player games.

This is the bar I saw used by ETAPrime. There are a lot of USB versions of the Wii Sensor Bar, but they aren't the kind with the built in bluetooth to pair the WiiMote by itself. I don't know that you can't use a computer with built in Bluetooth in that case or not, it seems possible but maybe a little far fetched to use the slightly cheaper plain usb models. Though if you don't enjoy building it yourself it is basically an out of the box usable system, I do have WiiMotes around and the Gun holder things if I wanted to go that way all I need is the proper sensor bar.
 
May 22, 2019
650
312
63
The thing to remember about the sensor bar is that it's not actually a sensor bar. It's an emitter. It's literally just two IR LEDs that shine out toward the player. The sensor is a camera in the front of the Wiimote.

On the button...you hold the button to move and release it to freeze the cursor. For something like a gun, you'd probably want to double-click it to let the cursor move freely (without holding the button.)

I did play some Duck Hunt with a Wiimote... but not a whole lot. It's been a long time since I've used the Wii.
 

Markeno

Member
Jul 19, 2019
98
40
18
hobbytronics.home.blog
I didn't even know they had Duck Hunt for the Wii or I would have probably gotten it. I really don't know how it worked compared to the original version, which is what I always played. My cousin said the Wii is what she had played it on and not the original Nintendo version with the light gun when she was trying out the Air Mouse Gun last week on the arcarde. Maybe ETAPrime mentioned the Wii version in the video too, I really don't remember. The DolphinBar does have more in it than the original bar, being it has the bluetooth pairing, and I think some configuration for the bar placement and a few other things, which is why I wonder if it can be done without that and a regular "dumb" bar and pairing it directly to the Pi or Computer via Bluetooth. That would be why the USB bars work on the Wii, they are just leds using the usb for power instead of that Wii specific connector when then should just be power as well.

There is plenty of capability in the Pro Micro to add the freeze button as mentioned. I haven't ever seen anyone else make something based on one of my projects, so I don't expect to see it happen unless I get way to much free time. Mostly if it turned out to be something I wanted to have around the shop at work. We could certainly use some Air Mice there if they were practical. So many projects so little time.
 
Last edited:
  • Like
Reactions: TomXP411