Here are the explanations of the codes.
To rotate the servo in pin 1 in Microbit and pause 1000 milliseconds (1 second)
pin1.write_analog(180)
sleep(1000)
To turn on the LED eye in pin 1 in Microbit and pause 1000 milliseconds (1 second)
pin1.write_digital(0)
sleep(1000)
To make the robot talks, first import the speech module. I used 2 types of speak commands, which are "speech.pronounce" and "speech.say".
When using "speech.say", we need to add some words inside the parentheses after the command as parameters.
speech.say("Let's play with me.", speed=92, pitch=60, throat=190, mouth=190)
We want the robot to talk " Let's play with me." With speed, pitch, throat, and mouth as we desired. To know more about these parameters, click this preference guide.
When we use "speech.pronounce", we use Phonemes as the parameter. For more information about phonemes, click this link.
speech.pronounce("Woh5oh3t ahahr yuhuh duhuhihihnx nnahah3uh5uh8", speed=92, pitch=60, throat=190, mouth=190)
In the code above, we make the robot to talk, "What are you doing now?"
Just play around with the speech command as you desired.
Save and download the code into the HEX file.
Microbit Case
We need to build the case for Microbit, so the Microbit could stand in place in the body of the robot. To make it, I used the simple shape of a box with dimension:
Length: 66 mm
Width: 21 mm
Height: 50 mm
Cut the box with some box holes as shown in the pictures. To make it easier, use the Microbit feature from the Tinkercad circuit.
Body- front part
For the front body, drop a box in the work area. Make a hole in the cylinder on the top with the same measurement as the hole in the head. Make some holes for the speaker,
Microbit, and the servo. Add four placeholders for placing the screws on each corner.
Body- back part
For the back part of the body, use two boxes, and stack them. The dimension should be the same as the front part of the body and the head. Group them together.
Legs
For the legs, use a box and combine it with a wedge. For the dimension, see the images. Group them together.
Hands
For making hand, drag and drop two roofs into the work area. Cut each roof with a box hole. Group them together. Duplicate the hands, so you have two hands now.
Head
Use a box for the head. Make some holes for the back part of the head. Make a placeholder for the screw.
Mouth
For the mouth, use a sphere and resize it as shown in the image.
Tail
Make the same shape as a mouth for the tail, only it is wider.
Prototype and Test
In doing an electronic project, it is crucial to make the prototype before assembling the electronic circuit.
By building a prototype, we can test whether our code and electrical circuits are correct or not. The test is quite successful. All electrical components are working smoothly.
Printing
Save each of the parts of the 3D Model into .stl files. Using Cura slicer, slice the .stl files and print them with the color of PLA filament as you desired. The printing settings are layer height 0.2 mm, infill 20%, using brim, and no support, except the Microbit case.
After printing
Remove the support in the Microbit case after printing.
Drilling After Printing
Make holes for the eyes to the head casing. I use a Makita drill to make the holes. Drill two holes in the head and measure the holes for LED about a diameter of 5 mm.
Also, drill five holes for bolting the body and drill two more holes for bolting the hands.
Tidying the Speaker
I used a speaker from my old microphone set. Because of it, the speaker's edges are not tidy. Cut the excess of the speaker and file with Dremel rotary tool.
Assemble the Printing Parts
Glue the mouth to the front body.
Glue the tail to the back part of the body.
Assemble the legs to the body and finally, glue the head to the body.
Build the Electrical Circuit
- Put the Microbit in the case.
- Insert alligator clips to pin 0 (red), 1 (yellow), 2 (white), and Gnd (black).
- Place the servos on each side as shown in the picture and glue them to the body.
- Solder the LEDs with wires. Red wires connect to the positive legs of LED and black wires connect to the negative legs. Insert the LEDs to the head and secure them with electrical tape.
- Connect all the alligator clip wires like in the previous prototype.
Construct the Robot
Upload the hex file to the Microbit. Put the Microbit and speaker inside the enclosure. Connect the Microbit with the batteries. Tidy up all the wires and secure them with electrical tape.
Close the enclosure with screws. (We need 5 small screws).
Attach the hands with servos.
Final Result and Test the Robot
Here is the final result of the Microbit Talking Robot.
If we press button A, it will show some images of hearts and smile first and then, turn on the LED for the right eye, and rotate the right hand. It will have the same condition if we press button B, only this time for the left side.
Note: I installed Microbit upside down due to the tight enclosure, so the result would be the opposite of my previous code.