Skip to content

Instantly share code, notes, and snippets.

@cnburger
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cnburger/aec9dc20161f95acd78d to your computer and use it in GitHub Desktop.
Save cnburger/aec9dc20161f95acd78d to your computer and use it in GitHub Desktop.
Voice Recognizer Posting to Facebook and Twitter via 1sheeld and Arduino
//Not all this code is my code. This code is part of 1Sheeld.com code. It is part of their simple example-Voice Recognizer
/* if you post to much to facebook ant twitter in a short amout of time you wil not be able to post anything for a while*/
/*Keep by 140 characters when using Twitter otherwize it will not tweet*/
/* Include 1Sheeld library. */
#include <OneSheeld.h>
/* Voice commands set by the user. */
//Voice commands the 1sheeld is going to react to -- Set by the user--
const char tweetCommand[] = "tweet"; //Change the word in the brackets to your preffered word
const char facebookpostCommand[] = "post on facebook"; //DO NOT USE CAPITALS
const char TweetPostCommand[] = "let them know";
// add more commands just change this >>TweetPost<<-Command[] change the Tweet post to another name and give it a value. copy one of the functions below and edit it to your new name
void setup()
{
/* Start Communication. */
OneSheeld.begin();
/* Error Commands handiling. */
VoiceRecognition.setOnError(error);
VoiceRecognition.start();
}
void loop ()
{
/* Check if new command received. */
if(VoiceRecognition.isNewCommandReceived())
{
/* Compare the tweet command. */
if(!strcmp(tweetCommand,VoiceRecognition.getLastCommand()))
{
//When "tweet" is heard the 1sheeld will post this in twitter
Twitter.tweet("Tweeting from a #1Sheeld. Using my voice! @christiaanneil");
delay(300); //wait 300 miliseconds
}
/* Compare the facebook command. */
else if (!strcmp(facebookpostCommand,VoiceRecognition.getLastCommand()))
{
/* Post to facebook the following message if "post on facebook is heard". */
Facebook.post("I'm posting to facebook using my voice this is crazy");
delay(300);
}
/* Compare the Tweet and Post command. */
else if (!strcmp(TweetPostCommand,VoiceRecognition.getLastCommand()))
{
/* Post and Tweet the following two messages to Facebook and twitter. */
Twitter.tweet("Two is beter than one");
Facebook.post("I'm Posting to Facebook ant twitter at the same time using my voice!! :Whatch this tutorial on https://www.youtube.com/channel/UC-ImMgP4Y337O_BithB6yPA");
delay(300); //Sleep 300 miliseconds
}
}
}
/* Error checking function. */ //1Sheeld's code www.1sheeld.com
void error(byte errorData)
{
/* Switch on error and print it on the terminal. */
switch(errorData)
{
case NETWORK_TIMEOUT_ERROR: Terminal.println("Network timeout");break;
case NETWORK_ERROR: Terminal.println("Network Error");break;
case AUDIO_ERROR: Terminal.println("Audio error");break;
case SERVER_ERROR: Terminal.println("No Server");break;
case SPEECH_TIMEOUT_ERROR: Terminal.println("Speech timeout");break;
case NO_MATCH_ERROR: Terminal.println("No match");break;
case RECOGNIZER_BUSY_ERROR: Terminal.println("Busy");break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment