AI Talking Dinosaur - Educational Toy From Recycled Materials♻️
by be_riddickulous in Circuits > Raspberry Pi
2190 Views, 14 Favorites, 0 Comments
AI Talking Dinosaur - Educational Toy From Recycled Materials♻️



I designed an AI-powered educational toy that makes learning colors and shapes fun, screen-free, and truly interactive. While it’s built for young children, adults can’t resist playing with it too! 🦖✨
Shaped like a friendly dinosaur with a movable mouth, the toy talks to the child, prompting them to find specific colors or shapes. When a piece is placed in its mouth, a built-in camera and AI model instantly recognize the object, give real-time voice feedback, and light up an RGB LED in response. Correct pieces are "swallowed" with encouragement, while incorrect ones are gently rejected. 🎤💡
It’s more than just a toy - it’s a playful way to introduce children to technology and support early development. Plus, it’s a great chance to repurpose recycled materials into something both adorable and meaningful. ♻️
I had so much fun making it, and I hope you will too!
Supplies








Hardware Components
- Raspberry Pi 5 – Runs logic for LED and servo motor control (older models also work)
- USB Webcam – Captures images of objects placed in the dinosaur’s mouth
- Servo Motor – Opens and closes the dinosaur’s mouth
- 8 RGB LED Module – Provides consistent lighting for image capture, changes color for feedback
- Small Speaker – Plays pre-recorded voice prompts and feedback
- Laptop – Hosts and runs the AI model, processes webcam input, and handles audio playback
- Physical Colored Pieces – Used for interaction and data collection
- Male-to-Female Jumper Cables – Connect LED and servo. If your cables are too short, you can extend the length by chaining two or three cables together.
- MicroSD Card – required to run the Pi
Crafting Materials
- Recycled Packaging Materials – Plastic bottles (1.5 L), plastic cups, thick paper, polystyrene pieces, 2 rubber bands
- Papier-Mâché – wrapping paper strips, PVA glue and water mixture
- Super-Fine Papier-Mâché Mix – Optional; can be bought or made for smoother finishing
- Base Layer for Paint – Gesso or similar primer
- Acrylic Paints – Various colors for finishing touches
- Paintbrushes – For applying glue and paint
- Craft Glue or Hot Glue Gun – For assembling parts
- Paper tape – For shaping and reinforcing the structure
- Scissors or Craft Knife – For cutting materials
- Bolt – Used to hinge the dinosaur’s jaw
- Wooden Shapes (Various Colors): Used as objects for play and AI detection
- Optional Decorations – Plastic eyes, eyelashes or other fun details to bring the toy to life
To make things easy, I’ve added a complete bill of materials with direct links to online stores - so you can start building right away!
Downloads
Prepare Your Raspberry Pi



Setup Instructions for Raspberry Pi with Servo and LED
- Prepare your Raspberry Pi and hardware.
- Install Raspberry Pi OS
- Download and install the Raspberry Pi Imager on your computer.
- Use it to write a fresh Raspberry Pi OS image onto your microSD card. Note: This will erase all existing data on the card.
- Insert the microSD card into your Raspberry Pi and power it on.
- 👉 Need help with setup? Check out the Getting started - Raspberry Pi Documentation for step-by-step guidance.
- Connect your components
- Use jumper wires to connect the components to your Raspberry Pi.
- For the LED, I used a WS2812 SPI driver, which communicates with WS2812 LEDs over the SPI interface. This is a workaround since WS2812 LEDs typically require precise timing on a single GPIO pin. Using SPI offloads timing to the SPI peripheral, simplifying control.
- Connect the LED data line to physical pin 19 (GPIO 10).
- Connect the servo signal wire to physical pin 12 (GPIO 18).
- Use 5V power from pin 2 or 4, and ground from any of these pins: 6, 9, 14, 20, 25, 30, 34, or 39, for powering both the servo and the LED. ⚠️Double check the wiring - mixing up the ground and 5V connections can permanently damage your RasPi or/and the connected components.
- Disable I2C (optional)
- To avoid pin conflicts and save system resources, disable I2C via raspi-config under Interface Options.
- Test your setup
- Run your test code (for example, the code from step 3).
- The servo arm should move, and the LED should change colors if everything is connected and configured correctly.
Build the Head of the Toy Dinosaur

.jpg)

.jpg)


Now it’s time to build the head of the toy dinosaur. Doing this at an early stage is important because it allows you to collect training data in a controlled environment. By capturing images inside the toy’s mouth - with an LED installed - you ensure consistent lighting and background. This helps your AI model learn more accurately, and reduces the need for a large dataset or extensive image augmentation.
🛠️ Assembly Instructions:
- Carve a plastic bottle lengthwise to form the two parts of the mouth: the bottom and top jaws.
- Attach a plastic cup to the bottle to serve as the neck (see the photo). This will later connect the head to the body.
- Use additional bottle parts to shape the top and back of the head, giving it structure and volume.
- Use tape to hold the parts temporarily in place and test the alignment.
- Once you're satisfied with the shape, secure all parts with a hot glue gun.
🎨 Papier-Mâché Covering:
- Start covering the plastic frame with papier-mâché using medium-sized strips of packaging paper.
- Mix 50% PVA glue and 50% water, and apply it to both sides of each strip using a brush.
- Apply the strips over the plastic and smooth them. You'll need about 5 layers if you want to remove the plastic base later.
- Let it dry completely.
👉Tip: Keep the plastic base for the bottom jaw - it’s smoother than paper and makes it easier for pieces to slide into the toy’s body.
⚙️ Add the Mouth Mechanism:
- Position the bottom jaw inside the upper jaw and temporarily secure it with paper tape.
- Use your camera to test the view:
- Place a colorful playing piece inside the mouth.
- The camera should clearly see the entire surface of the bottom jaw. You can adjust the position of both the camera and the jaw to achieve the perfect view.
- Avoid angles where the camera sees past the jaw or inside the toy’s body.
- Once the view is correct, mark the hinge point positions on both sides.
- Remove the bottom jaw and:
- Create an opening in the plastic to insert the servo motor (I used a heated metal skewer to melt a hole).
- Glue the servo securely into this opening.
- Attach the servo arm, then:
- Reinsert the bottom jaw.
- Mark where the servo arm will meet the inner wall of the upper jaw.
- Remove the arm again and glue it to the marked position inside the upper jaw.
- On the opposite side, drill a hole through both jaws to act as a hinge.
- Insert a bolt to create the jaw’s pivot point so the bottom jaw can move freely.
Test the Jaw Mechanism
Once everything is assembled, it’s time to test the servo motor and make sure the mouth moves as intended.
- Power up the servo and observe its range of motion.
- Ensure the mouth opens wide enough for a child to easily insert pieces.
- When the servo closes the mouth, it should do so at an angle that gently pushes the piece downward, allowing it to slide into the toy’s belly.
- If needed, adjust the servo arm position or hinge alignment to improve the motion.
Getting this right now will ensure smooth gameplay later.
You can use this Python code:
Install the LED and Camera Inside the Mouth



Now that the jaw mechanism works, it’s time to install the LED and webcam inside the toy’s mouth. These components are essential for both gameplay and collecting high-quality training images for your AI model. I removed the bottom jaw temporarily for easier access.
🧰 What I Used:
- An 8 LED module for consistent lighting
- A USB webcam or camera module for image capture
- Polystyrene pieces to create mounting cushions
- Elastic bands to hold the components in place
- Hot glue
- Paper tape
🛠️ Assembly Instructions:
- Create cushioned mounts: Cut small pieces of polystyrene to serve as cushioned bases for the camera and LED.
- Attach cushions to the upper jaw: Wrap elastic bands around the polystyrene, then hot-glue the cushions to the ceiling of the upper jaw.
- Position the camera: Carefully insert the camera module under the elastics. Take your time here - positioning is critical. You want a clear view of the pieces being inserted, and the camera must not be obstructed by the moving jaw or servo. This may require some trial and error and precise measuring. 👉Tip: you might want to use a camera with a smaller field of view (50 degrees).
- Insert the LED: Place the LED module next to the camera, also held by the elastic band. It should illuminate the area evenly without creating shadows.
- Secure the wires: Use paper tape to neatly attach all wiring along the back inner wall of the head. This keeps wires safely out of the way of moving parts and the sliding pieces.
Collect the Dataset for AI Training
.jpg)
Now that the camera and lighting are in place, it’s time to build your dataset by capturing images of the toy pieces inside the mouth. This data will be used to train the AI model to recognize shapes and colors accurately. 🚀If your colorful pieces look similar to mine, you can also download a ready-made model I’ve trained (see the last step for the link).
🧩 What to Do:
- Insert one piece at a time into the toy’s mouth.
- Capture images using Python (see sample code below).
- Vary the angle and position of each piece to add diversity.
- Take around 20 photos per piece.
For example, I used:
- 5 shapes × 5 colors = 25 unique pieces
- 20 images per piece = 500 total
👉 Make sure to collect an equal number of images for each piece to avoid class imbalance, which can reduce your model’s accuracy.
➕ Additional Images to Include:
- Multiple pieces at once – This helps the model learn to reject invalid inputs (e.g., when a child inserts two or more pieces at the same time).
- Empty background – Use these as negative examples to teach the model what “no piece” looks like.
- Other objects – Include items like pencils, fingers, or wrappers etc. to help the model ignore irrelevant items.
In total, I collected just over 800 images.
This is the code you can run to take photos:
Annotate Your Dataset for Shapes



Once you've collected your images, the next step is to upload and label them using Roboflow, a platform that makes it easy to annotate data and train AI models.
📝 Get Started:
- Create a Roboflow Account
- Go to roboflow.com, sign up (if you haven’t already), and log in.
- Create a New Project
- Click “Create New Project”
- Choose Instance Segmentation as the annotation type (this lets you outline shapes precisely).
- Name your project (e.g., "DinoToy_Shapes").
- Upload Your Images
- Upload all the photos you captured during the previous step.
- Define Your Classes
- For the shape recognition model, I defined these classes:
- square
- circle
- triangle
- pentagon
- star
- invalid (for multiple pieces inserted at once)
- Start Annotating
- Draw a segmentation mask around each visible shape.
- Assign it to the appropriate class.
🛑 Special Cases:
- For images with multiple pieces inserted together, outline all pieces as a single object, and label it as invalid.
- For images of background only or unrelated objects (like fingers, pencils, wrappers), use the "Mark Null" button. These will serve as negative examples during training.
This structured annotation process is crucial to help your AI model distinguish valid input from invalid or noisy data.
Create and Annotate the Color Dataset


After you’ve finished annotating shapes, you can use the same image dataset to train a second model for color recognition.
🔁 Duplicate Your Project:
- In Roboflow, go to your shape project.
- Click the three-dot menu next to the project name and choose “Duplicate Project”.
- Name the new project something like daino-colors.
🏷️ Update the Labels for Colors:
- Open each image in the new color project.
- Change the class names from shape labels to color labels, for example:
- square → yellow
- circle → red
- triangle → green
- and so on, depending on the actual color of the piece in that image.
- Leave images with multiple pieces labeled as invalid.
This method lets you reuse the same dataset while training two separate models - one to recognize shape, the other color - using consistent visual data.
Prepare the Datasets for Training

🧠 Prepare the Dataset for Training
Before exporting your dataset, you'll need to generate training images with augmentations to improve your model’s performance and reduce overfitting.
⚙️ On Roboflow:
- Go to the “Generate” tab in your new project.
- Choose the desired image size (I usesd 640×640) for YOLO training.
- Add augmentations like:
- Rotation (e.g., ±15°)
- Blur (slight)
- Brightness/Contrast adjustments (you can see the settings I used in the photo)
- Choose how many augmented copies you want per image (you can do max x3 on a free account).
- Click “Generate Dataset”.
Train the AI Model

Once your dataset is ready, it's time to train your model. You can do this either directly on Roboflow or locally on your computer (best if you have a dedicated GPU, offers better performance and control).
☁️ Option 1: Train on Roboflow (Quick & Cloud-Based)
Roboflow allows you to train directly in the browser. The benefit is you can turn off your computer while the training is happening.
💻 Option 2: Train Locally (Advanced + Flexible)
- Download Your Dataset
- In your Roboflow project, choose “Export Dataset”
- Select YOLOv11 format
- Download and unzip it on your computer
- Prepare Your Environment
- Create a folder for your project (e.g., ~/dino-yolo)
- Inside, create a Python file like train_shapes.py
- Install Required Packages: Make sure Python is installed, then install:
- Write Your Training Script
Below is an example (you’ll customize paths as needed):
Tips
- The dataset is small, so increase the number of epochs (e.g., 100+) to allow the model time to converge.
- You can try larger models like yolov11m.pt for higher accuracy (but they require more memory and training time).
- Make sure the path to your data.yaml file is correct.
Monitor Training
- You’ll see progress in the terminal: loss values, precision, recall, etc.
- You can build or paint the rest of your toy while it trains!
Evaluate Performance
- After training, check the confusion matrix and mAP values.
- If the model struggles with certain classes, consider collecting more images or improving the annotations, using a bigger model, adjusting some parameters, adding different augmentations, etc.
Retrieve Your Trained Model
- Your trained model will be saved as best.pt (depending on export settings).
- Repeat the training process for your second model (colors or shapes, depending on what you did first).
Build and Finish the Dinosaur’s Body

.jpg)


.jpg)


Now that the head is working and the electronics are tested, it's time to create the body of the dinosaur!
🛠️ Forming the Body Shape
- I used a gift package shaped like an Easter egg, but you can also use a balloon as a mold.
- Cover it with about 5 layers of papier-mâché. Let each layer dry before adding the next.
- Once fully dry, cut two circular openings:
- One at the top to attach the head
- One at the bottom to retrieve the inserted pieces
- Cut a small half-circle at the bottom to route cables safely into the body.
🦖 Adding Details
- Spikes: Cut strips from thick paper, roll them up into cones and glue them to the top of the head and along the back.
- Make teeth from the same paper and glue them to the upper jaw.
- Legs & Tail Base: Cut rough shapes for legs and a tail base out of thick cardboard, then glue them to the bottom of the body.
- You can use foil or polystyrene to add volume where needed (e.g., for shaping the head, legs, or tail).
- Secure the material with hot glue, then cover with paper strips.
✨ Smoothing and Finishing
- Apply a layer of super-fine papier-mâché to smooth the surface once the base structure is dry and firm.
- Use this layer to shape small details like nostrils, toes, and arms.
- Attach googly eyes and sculpt eyelids around them with the same fine material.
Painting and Sealing



- Once everything is fully dry, apply a base coat or primer for acrylic paint. This helps prevent the paint from soaking in unevenly.
- After the base coat dries, you can use 120-grit sandpaper to smooth out any bumps.
- Paint your dinosaur with your chosen acrylic colors. Let the first layer dry, then apply a second coat (I applied 3 layers).
- Once the paint is completely dry and you've achieved the desired coverage, you can apply a varnish to protect the surface and give your toy a polished finish. This is optional.
Create and Add Voice Lines

Now that your dinosaur is fully built and painted, let’s give it a voice!
✍️ Writing Your Lines
Start by making a list of all the phrases your dinosaur will say. These could include:
- “Great job!”
- “Try again!”
- “Put the red shape here.”
- “Let’s play a game!”
- Write everything down so you’re ready to generate the files.
🗣️ Using ElevenLabs
Go to https://elevenlabs.io and try out their text-to-speech tool.
- You can create some voice files for free, but note there’s a limit - after that, you’ll need to purchase a one-month subscription.
- Choose a voice you like. Try a few different ones to see what fits your toy best!
- Paste your phrases one by one and generate the audio.
- Download the audio files and save them in your project folder (e.g., in a subfolder called audio).
🐍 Playing Audio in Python
To play the voice lines, use the pygame module in Python.
🔊 Place the speaker in the belly of the dinosaur.
Writing the Game Code
Now it’s time to add the logic that brings everything together.
- You can write your own game rules based on how you want the dinosaur to respond.
- Or, check out my code on GitHub for inspiration or reuse:
- 🔗 github.com/howest-mct/2024-2025-projectone-ctai-RiddickNataliia
🧪 Final Testing
Try out the toy yourself to make sure everything works smoothly - voice, lights, movement, and recognition. Once you're happy, invite children to test it out.
🎉 Great Job!
You’ve built an interactive AI dinosaur toy. Time to celebrate!
If you make this project, I would love to see how it turned out, so please reach out 🧡