[Kids Project] Piyo Piyo from Smartphone

Make things

Create a Bird with motor and speaker, and control it from a smartphone!


How to make


First, create a base for a bird. Cut a circle from cardboard and make a tiny hole for a servo motor.

Next, fix it on top of the servo motor with double-sided tape.

Attach servo hone like below image to the servo motor.

Create a bird with a paper cup, and decorate it freely.

Then, put it on the servo motor.

Fix cables like the image below.

Hardware connection

Connect parts to an obniz Board like the table and the image below by referring to Speaker Library and DC Motor Library.

obniz parts
0 [Speaker] signal
1 [Speaker] GND
9 [Servo Motor] signal
10 [Servo Motor] Vcc
11 [Servo Motor] GND

Supply power to the obniz Board and run the program below. The bird will move depending on the smartphone movement.

If you tilt your smartphone left and right, the bird moves in the direction of your tilted smartphone. If you tilt your smartphone up and down, the bird changes its chirping.


To get a value of an orientation of a smartphone, input “deviceorientation” for the first argument, and anonymous function for the second argument in “window.addEventListener” function.

Then, get the value like below.

Please read Detecting device orientation – Web API | MDN for details.

const beta = event.beta;
const gamma = event.gamma;
const alpha = event.alpha;