Introduction: Bluetooth Mouse With Ultrasonic Sensor and Photocell
So, a little introduction as to why I made this project. I'm currently looking to adopt a kitten into my new house. And after going trough some playable things for cats, I thought: why not make a toy myself. So, I made a Bluetooth mouse. You can control it using the app I made for android phones. Also, I made two modes. A input off mode where the mouse only responds if some object is close behind its back. And the normal input on where the user of the app can 'drive' the mouse.
Step 1: Materials
For the mouse you will need:
- 1x Arduino Uno
- 1x Breadboard
- 1x Solder board
- 2x Gearmotor with 360 decrees offset
- 1x 10k Ohm resistor
- 1x Arduino driver board L298N Dual H Bridge
- 1x HC-05 Bluetooth adaptor
- 1x Photocell Light resistor
- 1x Ultrasonic sensor
- 1x Piece of wood
- 2x Wheels that are able to fit the gearmotor
- 20x Tie-wraps
- 20x Female - Female Jumper Wires
- 20x Male - Male Jumper Wires
- 1x Phone with android on it
- 1x LED strip
- 1x 12v Battery
- 3x Buttons (any colour you like)
- 10x Piece of rope
Also, you will need an tool for the layout of the circuit and you will need an tool to make the . apk for your phone.
I used circuito.io for the layout of the circuit and Appinventor2 to make an easy prototype app for the android phone.
Step 2: The Frame
So, we are making a mouse. It has to be able to move around and to receive that goal, we make a frame for all the electronics. I used some wood and made it 10*14 cm. We attach the swivelling wheel and that'l be all for now.
Step 3: The Code
Download the codes below.
You should get:
Step 4: Testing the Input
To be sure that the Arduino; HC-05; L298n-H Brigde motor driver and the gear motors all work and receive input from the application on your device we test it. So, we have to wire all components as you can see in the circuit above.
NOTE: it also works with a 9v or 6v battery, the motors will just spin slower but that's okay.
Upload the ArduinoMouseTesting.ino to your Arduino Uno.
Now, download the ArduinoMouseApplication.apk on your mobile device and try to connect your phone with the HC-05.
When asked for a pin use 1234 or 0000.
So, when the Bluetooth connection has been made you can try to spin the motors by pushing forward or backwards buttons on the application.
If you are not getting an error everything is working and we can move on! :)
Step 5: Building on the Frame!
So, now it is time to add the wheels onto the gear-motors. But before we do that we have to put everything on the frame. I recommend to make some holes using a drill inside the frame, but this is optional and not necessary. Add the gear-motors on the same side of the swivelling wheel. The gear-motors should reach out left and right from the frame. Now use some tie-wraps or glue to put the gear-motors so that they are not able to leave. Also, put the battery on this side of the frame so we do have enough space on the other side of the frame.
Now, turn the frame and add the Arduino Uno at the front. Add the L298n-h driver on the back so its close by the gear-motors. Use tie-wraps or glue to put it all on the frame so it stays where it belongs.
You can add the wheels onto the gear-motors and the frame should be ready to go.
Step 6: Alright, Test It!
If everything is in order the mouse should be able to move around with the input you give from your mobile device. We have a moving mouse! :D
Step 7: Case Production!
We have a moving 'thing' but it doesn't really look at a mouse, at all. So, we are going to make something that hides all electronica nicely and also looks a bit like a mouse, a big mouse ^^.
First, we use Styrofoam to make a base that is very light and strong.
Second, we use some fabric to make the base fluffy and make it look like a mouse.
Third, we add some buttons as for the eyes and nose.
Fourth, we add some rope to the nose to make it even better.
Step 8: Upgrade 1: Photocell
So, we do have a moving mouse, but its kinda boring it can only move. I want to add more interactions so I made use of the Photocell. For this part we have to solder a bit on the solder board, we just need a little piece.
We take the Photocell; a 10k ohm resistor; and 3 jumper wires.
The 3 jumper wires should come from: 5v; gnd; and A0.
Also, we need an LED strip or normal LED (whatever you prefer).
Attach the - to gnd and the + to pin 6.
- Try to use as little tin as possible. You don't want to make an possible short circuit.
- Before adding the tin first make sure the solder is on preferred temperature.
- Expand the gnd(ground) and 5v ports from the Arduino using some heat shrink tubing. Add a few male - male wires on one side and only one female - female wire on the other side, use the heat shrink tubing to put the wires together.
Step 9: Upgrade 2: Ultrasonic Sensor
So, as I mentioned I want two modes. To receive this goal we add the ultrasonic sensor.
Add the vcc to 5v; the gnd to the gnd; trig to the 8 pin; echo to the 9 pin.
Now, just put the ultrasoon with a tie-wrap behind the L298n-h so it aimes behind the mouse.
Alright, now you can upload the ArduinoMouseController.ino code to your Arduino.
Step 10: Last Things
So, everything is ready!
We just put the case over the wires and its good to go!
Add the LED strip wherever you like, just make sure the Photocell is not underneath the case. If you want you can attach the case with some glue but I like it when I can easily detach the case to see whats inside :D.
4 years ago
What a fun idea for a cat toy! Thanks for sharing your creativity.