Components and supplies
1Sheeld
brushless dc pump
battery
Motor Shield V2.0
Android device
Arduino UNO
Tools and machines
Hot glue gun (generic)
wood 700*500*3 mm
Laser cutter (generic)
Apps and platforms
1sheeld
Project description
Code
code_01.ino
arduino
1/* 2 3 Text-To-Speech Shield 4 VOICE_RECOGNIZER_SHIELD 5 6 OPTIONAL: 7 To reduce the library compiled size and limit its memory usage, you 8 can specify which shields you want to include in your sketch by 9 defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 10 11*/ 12 13#define CUSTOM_SETTINGS 14#define INCLUDE_TEXT_TO_SPEECH_SHIELD 15#define INCLUDE_VOICE_RECOGNIZER_SHIELD 16 17/* Include 1Sheeld library. */ 18#include <OneSheeld.h> 19unsigned long previousMillis = 0; 20int counter = 0; 21/* A command which will be compared. */ 22const char firstCommand[] = "hello"; 23 24/* A command which will be compared. */ 25const char secondCommand[] = "yes"; 26 27/* A command which will be compared. */ 28const char thirdCommand[] = "10"; 29const char fourCommand[] = "20"; 30const char fiveCommand[] = "50"; 31 32int motorAPin1 = 8; 33int motorAPin2 = 11; 34int motorASpeedPin = 9; 35/* A name for the LED on pin 13. */ 36int ledPin = 13; 37 38void setup() 39{ 40 /* Start communication. */ 41 OneSheeld.begin(); 42 pinMode(motorAPin1, OUTPUT); // IN1 of motor A 43 pinMode(motorAPin2, OUTPUT); // IN2 of motor A 44 pinMode(motorASpeedPin, OUTPUT); // Speed of motor A 45 /* Set the LED pin as output. */ 46 pinMode(ledPin, OUTPUT); 47 VoiceRecognition.setOnNewCommand(&myFunction); 48 49} 50 51void loop() 52{ 53 unsigned long currentMillis = millis(); 54 55 if (currentMillis - previousMillis >= 5000) { 56 57 previousMillis = currentMillis; 58 59 /* start voice recognition. */ 60 VoiceRecognition.start(); 61 } 62} 63void myFunction (char *commandSpoken) 64 65{ 66 /* Check if the voice command is the desired one. */ 67 if (!strcmp(firstCommand, VoiceRecognition.getLastCommand()) && counter == 0) 68 { 69 /* 1Sheeld responds using text-to-speech. */ 70 TextToSpeech.say("hello"); 71 delay(2000); 72 TextToSpeech.say("please answer on the following questions"); 73 delay(2000); 74 TextToSpeech.say("if you agree say yes"); 75 counter = 1; 76 } 77 /* Check if the voice command is the desired one. */ 78 if (!strcmp(secondCommand, VoiceRecognition.getLastCommand())) 79 { 80 /* 1Sheeld responds using text-to-speech. */ 81 TextToSpeech.say("okay,what the sum of 4 plus 6 ?"); 82 } 83 /* Check if the voice command is the desired one. */ 84 if (!strcmp(thirdCommand, VoiceRecognition.getLastCommand())) 85 { 86 TextToSpeech.say("RIGHT"); 87 delay(2000); 88 TextToSpeech.say("seconde question"); 89 delay(2000); 90 TextToSpeech.say("eight plus twelve ?"); 91 delay(2000); 92 93 } 94 if (!strcmp(fourCommand, VoiceRecognition.getLastCommand())) 95 { 96 TextToSpeech.say("greet"); 97 delay(2000); 98 TextToSpeech.say("next question is"); 99 delay(2000); 100 TextToSpeech.say("20 plus 30 ?"); 101 delay(2000); 102 } 103 if (!strcmp(fiveCommand, VoiceRecognition.getLastCommand())) 104 { 105 TextToSpeech.say("congratulate you won"); 106 delay(2000); 107 TextToSpeech.say("please wait 5 second"); 108 delay(5000); 109 digitalWrite(motorAPin1, HIGH); // IN1 of motor A 110 digitalWrite(motorAPin2, LOW); // IN2 of motor A 111 digitalWrite(motorASpeedPin, HIGH); // Speed of motor A 112 digitalWrite(ledPin, HIGH); 113 delay(5000); 114 digitalWrite(motorAPin1, LOW); // IN1 of motor A 115 digitalWrite(motorAPin2, LOW); // IN2 of motor A 116 digitalWrite(motorASpeedPin, LOW); // Speed of motor A 117 delay(5000); 118 digitalWrite(motorAPin1, HIGH); // IN1 of motor A 119 digitalWrite(motorAPin2, LOW); // IN2 of motor A 120 digitalWrite(motorASpeedPin, HIGH); // Speed of motor A 121 digitalWrite(ledPin, HIGH); 122 delay(5000); 123 digitalWrite(motorAPin1, LOW); // IN1 of motor A 124 digitalWrite(motorAPin2, LOW); // IN2 of motor A 125 digitalWrite(motorASpeedPin, LOW); // Speed of motor A 126 delay(5000); 127 } 128} 129 130
code_01.ino
arduino
1/* 2 3 Text-To-Speech Shield 4 VOICE_RECOGNIZER_SHIELD 5 6 OPTIONAL: 7 To reduce the library compiled size and limit its memory usage, you 8 can specify which shields you want to include in your sketch by 9 defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 10 11*/ 12 13#define CUSTOM_SETTINGS 14#define INCLUDE_TEXT_TO_SPEECH_SHIELD 15#define INCLUDE_VOICE_RECOGNIZER_SHIELD 16 17/* Include 1Sheeld library. */ 18#include <OneSheeld.h> 19unsigned long previousMillis = 0; 20int counter = 0; 21/* A command which will be compared. */ 22const char firstCommand[] = "hello"; 23 24/* A command which will be compared. */ 25const char secondCommand[] = "yes"; 26 27/* A command which will be compared. */ 28const char thirdCommand[] = "10"; 29const char fourCommand[] = "20"; 30const char fiveCommand[] = "50"; 31 32int motorAPin1 = 8; 33int motorAPin2 = 11; 34int motorASpeedPin = 9; 35/* A name for the LED on pin 13. */ 36int ledPin = 13; 37 38void setup() 39{ 40 /* Start communication. */ 41 OneSheeld.begin(); 42 pinMode(motorAPin1, OUTPUT); // IN1 of motor A 43 pinMode(motorAPin2, OUTPUT); // IN2 of motor A 44 pinMode(motorASpeedPin, OUTPUT); // Speed of motor A 45 /* Set the LED pin as output. */ 46 pinMode(ledPin, OUTPUT); 47 VoiceRecognition.setOnNewCommand(&myFunction); 48 49} 50 51void loop() 52{ 53 unsigned long currentMillis = millis(); 54 55 if (currentMillis - previousMillis >= 5000) { 56 57 previousMillis = currentMillis; 58 59 /* start voice recognition. */ 60 VoiceRecognition.start(); 61 } 62} 63void myFunction (char *commandSpoken) 64 65{ 66 /* Check if the voice command is the desired one. */ 67 if (!strcmp(firstCommand, VoiceRecognition.getLastCommand()) && counter == 0) 68 { 69 /* 1Sheeld responds using text-to-speech. */ 70 TextToSpeech.say("hello"); 71 delay(2000); 72 TextToSpeech.say("please answer on the following questions"); 73 delay(2000); 74 TextToSpeech.say("if you agree say yes"); 75 counter = 1; 76 } 77 /* Check if the voice command is the desired one. */ 78 if (!strcmp(secondCommand, VoiceRecognition.getLastCommand())) 79 { 80 /* 1Sheeld responds using text-to-speech. */ 81 TextToSpeech.say("okay,what the sum of 4 plus 6 ?"); 82 } 83 /* Check if the voice command is the desired one. */ 84 if (!strcmp(thirdCommand, VoiceRecognition.getLastCommand())) 85 { 86 TextToSpeech.say("RIGHT"); 87 delay(2000); 88 TextToSpeech.say("seconde question"); 89 delay(2000); 90 TextToSpeech.say("eight plus twelve ?"); 91 delay(2000); 92 93 } 94 if (!strcmp(fourCommand, VoiceRecognition.getLastCommand())) 95 { 96 TextToSpeech.say("greet"); 97 delay(2000); 98 TextToSpeech.say("next question is"); 99 delay(2000); 100 TextToSpeech.say("20 plus 30 ?"); 101 delay(2000); 102 } 103 if (!strcmp(fiveCommand, VoiceRecognition.getLastCommand())) 104 { 105 TextToSpeech.say("congratulate you won"); 106 delay(2000); 107 TextToSpeech.say("please wait 5 second"); 108 delay(5000); 109 digitalWrite(motorAPin1, HIGH); // IN1 of motor A 110 digitalWrite(motorAPin2, LOW); // IN2 of motor A 111 digitalWrite(motorASpeedPin, HIGH); // Speed of motor A 112 digitalWrite(ledPin, HIGH); 113 delay(5000); 114 digitalWrite(motorAPin1, LOW); // IN1 of motor A 115 digitalWrite(motorAPin2, LOW); // IN2 of motor A 116 digitalWrite(motorASpeedPin, LOW); // Speed of motor A 117 delay(5000); 118 digitalWrite(motorAPin1, HIGH); // IN1 of motor A 119 digitalWrite(motorAPin2, LOW); // IN2 of motor A 120 digitalWrite(motorASpeedPin, HIGH); // Speed of motor A 121 digitalWrite(ledPin, HIGH); 122 delay(5000); 123 digitalWrite(motorAPin1, LOW); // IN1 of motor A 124 digitalWrite(motorAPin2, LOW); // IN2 of motor A 125 digitalWrite(motorASpeedPin, LOW); // Speed of motor A 126 delay(5000); 127 } 128} 129 130
Documentation
box_trick_jOqYoJW0QW.dxf
dxf for the box
box_trick_jOqYoJW0QW.dxf
Comments
Only logged in users can leave comments
raef_madin
0 Followers
•0 Projects
Table of contents
Intro
3
0