My pet dog loves playing with toys especially ones he can chase! I built a robotic ball that switches on and rolls away whenever he interacts with it, notifies me via my mobile phone where I can then take over control and finally powers down when the fun is over to save battery.
The ball uses a d1 mini micro-controller, programmed using Arduino and is put together using some 3D-printed parts and some cheap, readily available components.
For this project you will need:
- 17cm diameter Hamster Ball (https://amzn.to/2PShVKr)
- 2 x DC Motors and Wheels (https://amzn.to/2PQkm0n) Or (https://www.banggood.com/custlink/GKmGBes7RB)
- Wemos D1 Mini (https://www.banggood.com/custlink/GDmv4JTGLi)
- WS2812B RGB LED (https://www.banggood.com/custlink/KK3GBr7RcZ)
- 2N2222 Transistor (https://www.banggood.com/custlink/DDm3eJ7DbH)
- Buzzer (https://www.banggood.com/custlink/Dv33g6N1hQ)
- KY-002 Shock Sensor (https://amzn.to/2oOvHTm)
- 2 x 14500 3.7V Li-Ion Batteries (https://www.banggood.com/custlink/m33GB6n1Jv)
- AA Battery Holder with switch (https://www.banggood.com/custlink/mGDv4BnTpt)
- L298N Motor Driver Board (https://amzn.to/2pM7PAd) Or (https://www.banggood.com/custlink/mvGG0gbTco)
- Various length wires
- Vaious M2 and M3 screws
- 5 x 3D-Printed parts
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Print the Parts
You will require 5 3D printed parts in total. The motor base and cover which hold the 2 motors firmly in place and to which the D1 mini and motor driver board are attached as well as 2 ball heads which attach to the guide arm.
Print with a layer height of around 0.2mm and infill of 20% and they should come out just fine.
Step 2: Solder Wires to the Motors
Solder 2 wires to each of the motors
Step 3: Position and Secure the Motors
Position the 2 DC motors within the motor base and secure using appropriate length M3 screws and the fixing positions (2 for each motor).
Step 4: Attach the Motor Cover
Position the motor cover and secure using 4 x M3 screws.
Step 5: Attach the D1 Mini and Motor Driver Board
Using some M2 screws, attach the D1 mini and the motor drive board to the cover.
Step 6: Connect Components
Connect all the components using the schematic remembering to remove the 2 jumpers from the L298N board as shown. Attach the wheels to the motors. Secure the battery cover to the underside of the motor housing using hot glue. Use hot glue to tidy and secure all the loose cables (You may want to skip to the next section and test everything first!).
A bit of theory...
The shock sensor is attached to the reset pin to enable the D1 mini to wake from deep sleep which we use to save power whenever the robot is not being played with. The transistor is used as a switch to ensure that these signals are not received when the device is switched on or else as soon as the robot ball moves it would simply reset itself again and again.
The transistor requires signal from an output pin of the micro-controller to operate. Fortunately for us, the pin D0 (GPIO16) is automatically set to HIGH when in deep sleep and we can simply set it to LOW as soon as the sketch starts up to prevent any subsequent resets. The pin automatically sets back to HIGH again to 'arm' the sensor as soon as the micro-controller returns to deep sleep.
Step 7: Configure the Sketch
Ensure you have the following libraries installed. These can be installed using the libraries manager from within the Arduino IDE if not. Newer versions may work but have not been tested.
- FastLED v3.3.2
- Blynk v0.6.1
The following library must be installed manually by moving its contents into the Arduino libraries folder:
- ESP8266WiFi Library v2.4.2 – https://github.com/esp8266/Arduino
Open the sketch in the Arduino IDE. Change the 3 lines shown below to reflect your own WiFi credentials and your Blynk Auth Token (see Blynk App section to locate this).
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid = "YOUR WIFI SSD HERE";
char pass = "YOUR WIFI PASS HERE";
// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon).
char auth = "YOUR AUTH TOKEN HERE";
NOTE: You will need to remove the pin from D0 before you will be able to upload sketches. Re-connect it after the upload is complete.
Connect the D1 Mini to the PC using a micro-USB, ensure that the settings shown are used, the correct COM Port is set and upload the sketch.
The ball should now reboot and connect to your WiFi network. It will become controllable via your own mobile Blynk app after completing the Blynk section of this guide. To troubleshoot any faults, with the D1 mini connected to the PC, use the Serial monitor in the Arduino IDE to help diagnose.
Step 8: Blynk Mobile App
The ball is controlled using a Blynk web app. Blynk is an IoT platform free for prototyping/non-commercial use.
Begin by downloading Blynk from the Android Play or Apple App Store.
Create an account and Scan the QR-code above from within the app.
Under the project settings locate the projects Auth Token by emailing to your account or using the Copy all feature.
Copy the auth token to the android sketch, upload and you should be good to go!
Step 9: Insert Robot Into the Ball
Gently position the completed electronics into the ball. Once inside, attach the guide arm with a guide ball snapped in place either side.
Note: The photo shows the guide arm and balls in place prior to insertion as a guide only. You will not be able to position the robot into the ball if you do things in this order!
Secure the guide arm in place with a zip tie, velcro strap or rubber band.
Insert 2 x 3.7V batteries, turn on the power switch and close the lid on the ball.
Step 10: Play Away...
Set up your robot ball somewhere for your pet to find and as soon as they start interacting with it watch it come to life and entertain them all by itself. If you prefer, use the mobile app to play back with some skilful moves. Enjoy and if you liked this project please vote for us in the Robot contest. Thanks.
This is an entry in the