Make the alarm clock that escapes when you try to stop with AI Robot Kit materials.
The following is the system flow.
- The smartphone displaying an alarm clock is put on the box with tires and a caster.
- The alarm will go off on setting time.
- The box with the alarm clock will escape when you try to stop the alarm clock.
- GP2Y0A21YK0F(Infrared distance sensor)*
- DC Motor*
- obniz Board*
- power supply for obniz
- tire* x2
- a box for body*
* included in AI Robot Kit.
How to make
Assemble the body up to Step.5 referring to Materials and Assemble of AI Robot Kit Lesson. Please don’t put an Infrared distance sensor yet.
|0||DC Motor1 OUT1|
|1||DC Motor1 OUT2|
|7||GP2Y0A21YK0F(Infrared distance sensor) Vcc|
|8||GP2Y0A21YK0F(Infrared distance sensor) GND|
|9||GP2Y0A21YK0F(Infrared distance sensor) signal|
|10||DC Motor2 OUT1|
|11||DC Motor2 OUT2|
At this time, pull the wires of DC Motor from the holes and connect them to the obniz. Also, attach the infrared distance sensor to the front of the body and extend the wires to the obniz. (Here, I’m sticking wires at the bottom.)
In this program, the alarm will go off on setting time and if you bring your hand to stop the alarm, the alarm will escape.
Use audio tags of HTML to go off the alarm. Please read <audio>: The Embed Audio element – MDN for details.
Prepare a sound file for alarm and save as “alarm_sound.mp3.” (Here, I used this sound file and edited for alarm.)
Then, select the Repository from obniz’s console and save the program as your favorite file name.
Also, upload the sound file to your repository from “upload.”
Connect obniz to the power and run the program from obniz’ console and adjust the position of the infrared distance sensor.
The alarm will escape if you bring your hand to stop the alarm. (Please adjust DIS_THOREHOLD value(code.js line 2)).