Control a flag waver using speech recognition.If you say “I'm home!”, the flag with the word “Welcome back” moves.
This youtube page says "Tadaima".
The word "Tadaima" is Japanese. It means "I'm home" in English.
The flags is witten "おかえり" means "welcome back".
Materials*included in Starter Kit
How to makeHardware connection
Connect the servo motor to the obniz Borad referencing to the library of servo motor.
Software
Uses the browser’s speech recognition API called Web Speech API.Check the browser compatibility here.
recognition.onresult is executed when you finished speaking the word.
If the obniz recognizes the word as “I'm home!, ” it moves the servo motor to wave the flag.
Program<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
/>
<link rel="stylesheet" href="/css/starter-sample.css" />
<script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
<script src="https://unpkg.com/obniz@3.x/obniz.js"></script>
<style>
h1 {
margin-top: 50px;
text-align: center;
}
</style>
</head>
<body>
<div id="obniz-debug"></div>
<h1 id="voice"></h1>
<script>
const obniz = new Obniz("OBNIZ_ID_HERE");
obniz.onconnect = async function() {
const servo = obniz.wired("ServoMotor", { gnd: 0, vcc: 1, signal: 2 });
SpeechRecognition =
window.webkitSpeechRecognition || window.SpeechRecognition;
const recognition = new SpeechRecognition();
recognition.onresult = async event => {
document.getElementById("voice").innerHTML = event.results[0][0].transcript;
let angle_list = [40, 140, 40, 140];
if (event.results[0][0].transcript == "I'm back") {
for (let i = 0; i < angle_list.length; i++) {
servo.angle(angle_list[i]);
await obniz.wait(1000);
}
}
};
recognition.start();
};
</script>
</body>
</html>
What is obniz?Before we get into the project, let's look into obniz.
Here → obniz for DIY electronics
obniz is a cloud-connected IoT development board. You can program on the web browser of any smartphone or computer and the command is sent to obniz through the internet via obniz cloud. By connecting the obniz to the cloud through wifi, users can remotely control devices that are physically connected to obniz.
Thanks to this cloud based approach, you can program with Python, Javascript, or other languages you prefer and control hardware directly. You don't need to integrate firmware into the device side. Recording and analyzing data is also easy with obniz cloud service.
Want to control hardware things with your current Python or Javascript skill? Want to start IoT project but don't know where to start? Want to learn programming with languages you prefer?
obniz will help you broaden your viewpoint and develop both your SW and HW skills.
For more information, please visit our official website → Official Website
Where to get obniz board? → Amazon /Official Store
Comments
Please log in or sign up to comment.