raef_madin
Published © CERN-OHL

April Fool Project

Making a smartphone ask questions that somebody answers to get the gift, but the gift is being sprayed with water.

BeginnerFull instructions provided2,224

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
1Sheeld
1Sheeld
×1
Android device
Android device
or apple iphone
×1
brushless dc pump
×1
battery
pump work on 12v
×1
Motor Shield V2.0
×1

Software apps and online services

1sheeld

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Laser cutter (generic)
Laser cutter (generic)
wood 700*500*3 mm

Story

Read more

Custom parts and enclosures

box_trick_jOqYoJW0QW.dxf

dxf for the box

Code

code_01.ino

Arduino
/*

  Text-To-Speech Shield 
  VOICE_RECOGNIZER_SHIELD 

  OPTIONAL:
  To reduce the library compiled size and limit its memory usage, you
  can specify which shields you want to include in your sketch by
  defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define.

*/

#define CUSTOM_SETTINGS
#define INCLUDE_TEXT_TO_SPEECH_SHIELD
#define INCLUDE_VOICE_RECOGNIZER_SHIELD

/* Include 1Sheeld library. */
#include <OneSheeld.h>
unsigned long previousMillis = 0;
int counter = 0; 
/* A command which will be compared. */
const char firstCommand[] = "hello";

/* A command which will be compared. */
const char secondCommand[] = "yes";

/* A command which will be compared. */
const char thirdCommand[] = "10";
const char fourCommand[] = "20";
const char fiveCommand[] = "50";

int motorAPin1 = 8;
int motorAPin2 = 11;
int motorASpeedPin = 9;
/* A name for the LED on pin 13. */
int ledPin = 13;

void setup()
{
  /* Start communication. */
  OneSheeld.begin();
  pinMode(motorAPin1, OUTPUT);    // IN1 of motor A
  pinMode(motorAPin2, OUTPUT);    // IN2 of motor A
  pinMode(motorASpeedPin, OUTPUT); // Speed of motor A
  /* Set the LED pin as output. */
  pinMode(ledPin, OUTPUT);
  VoiceRecognition.setOnNewCommand(&myFunction);

}

void loop()
{
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= 5000) {

    previousMillis = currentMillis;

    /* start voice recognition. */
    VoiceRecognition.start();
  }
}
void myFunction (char *commandSpoken)

{ 
  /* Check if the voice command is the desired one. */
  if (!strcmp(firstCommand, VoiceRecognition.getLastCommand()) && counter == 0)
  {
    /* 1Sheeld responds using text-to-speech. */
    TextToSpeech.say("hello");
    delay(2000);
    TextToSpeech.say("please answer on the following questions");
    delay(2000);
    TextToSpeech.say("if you agree say yes");
    counter = 1;
  }
  /* Check if the voice command is the desired one. */
  if (!strcmp(secondCommand, VoiceRecognition.getLastCommand()))
  {
    /* 1Sheeld responds using text-to-speech. */
    TextToSpeech.say("okay,what the sum of 4 plus 6 ?");
  }
  /* Check if the voice command is the desired one. */
  if (!strcmp(thirdCommand, VoiceRecognition.getLastCommand()))
  {
    TextToSpeech.say("RIGHT");
    delay(2000);
    TextToSpeech.say("seconde question");
    delay(2000);
    TextToSpeech.say("eight plus twelve ?");
    delay(2000);

  }
  if (!strcmp(fourCommand, VoiceRecognition.getLastCommand()))
  {
    TextToSpeech.say("greet");
    delay(2000);
    TextToSpeech.say("next question is");
    delay(2000);
    TextToSpeech.say("20 plus 30 ?");
    delay(2000);
  }
  if (!strcmp(fiveCommand, VoiceRecognition.getLastCommand()))
  {
    TextToSpeech.say("congratulate you won");
    delay(2000);
    TextToSpeech.say("please wait 5 second");
    delay(5000);
    digitalWrite(motorAPin1, HIGH);    // IN1 of motor A
    digitalWrite(motorAPin2, LOW);    // IN2 of motor A
    digitalWrite(motorASpeedPin, HIGH); // Speed of motor A
    digitalWrite(ledPin, HIGH);
    delay(5000);
    digitalWrite(motorAPin1, LOW);    // IN1 of motor A
    digitalWrite(motorAPin2, LOW);    // IN2 of motor A
    digitalWrite(motorASpeedPin, LOW); // Speed of motor A
    delay(5000);
    digitalWrite(motorAPin1, HIGH);    // IN1 of motor A
    digitalWrite(motorAPin2, LOW);    // IN2 of motor A
    digitalWrite(motorASpeedPin, HIGH); // Speed of motor A
    digitalWrite(ledPin, HIGH);
    delay(5000);
    digitalWrite(motorAPin1, LOW);    // IN1 of motor A
    digitalWrite(motorAPin2, LOW);    // IN2 of motor A
    digitalWrite(motorASpeedPin, LOW); // Speed of motor A
    delay(5000);
  }
}

Credits

raef_madin

raef_madin

2 projects • 4 followers

Comments