Michael Sizemore
Published © CC BY

Hospitality HAL

Friendly, talking, robot door greeter for your maker space.

BeginnerFull instructions provided1,850
Hospitality HAL

Things used in this project

Story

Read more

Code

Untitled file

Arduino
/* Hospitality HAL code using 1Sheeld and Arduino Uno

By Michael Sizemore
5/14/2015

Hardware consists of Big Red Dome Button from sparkfun and a box of your choosing
Arduino simply controls the LED in the Big Red Dome Button to make it look like 
HAL is talking

*/

#include <OneSheeld.h>

const int pinLED = 9;

bool isConnected = false;
bool buttonPressed = false;

String name = "";

void setup()
{
	OneSheeld.begin();
	pinMode(pinLED, OUTPUT);
	
	randomSeed(analogRead(0));
}

void action()
{
	TextToSpeech.say("Welcome");
	HALspeaks(1000);
	OneSheeld.delay(1000);
	TextToSpeech.say("Okay, switch to the Voice Recognition shield and tell me your name");
	OneSheeld.delay(500);
	HALspeaks(3400);
	
	while((!VoiceRecognition.isNewCommandReceived()) && (OneSheeld.isAppConnected())){
		OneSheeld.delay(10);
	}

	name = VoiceRecognition.getLastCommand();
	
	TextToSpeech.say("Good to see you" + name + ", Are you arriving or leaving?");
	HALspeaks(3000);
	
	while((!VoiceRecognition.isNewCommandReceived()) && (OneSheeld.isAppConnected())){
		OneSheeld.delay(10);
	}

	if (!strcmp("arriving",VoiceRecognition.getLastCommand()))
	{
		TextToSpeech.say("Great! Welcome to the MakerHive");
		HALspeaks(2000);
		Camera.frontCapture();
		OneSheeld.delay(3000);
//		Twitter.tweetLastPicture(name + " just got to the MakerHive!", 0);
		Twitter.tweetLastPicture(name + " just got to the MakerHive!", 0);
		
	}
	else if (!strcmp("leaving",VoiceRecognition.getLastCommand())){
		TextToSpeech.say("Ok " + name +", see you next time!");
		HALspeaks(2000);
		Camera.frontCapture();
//		Twitter.tweetLastPicture("L8RS", 0);
		OneSheeld.delay(3000);
		Twitter.tweetLastPicture("Thanks for coming " + name, 0);
	}
	else TextToSpeech.say("I didn't catch any of that. Disconnect and try again.");

}

void HALspeaks (unsigned long duration)
{
	// Make the button LED pulse as if it were talking
	unsigned long startTime = millis();
	
	while ((millis()-startTime)<duration)
	{
		//HAL is talking
		int attackTime = random(0,300);
		int fadeTime = random(0,200);
		
		// ramp LED up
		for (int i = 0; i<attackTime; i++)
		{
			int j = map(i, 0, attackTime, 0, 255);
			analogWrite(pinLED, j);
			OneSheeld.delay(1);
		}
		
		// ramp LED down
		for (int i = fadeTime; i>1; i--)
		{
			int j = map(i, 0, fadeTime, 0, 255);
			analogWrite(pinLED, j);
			OneSheeld.delay(1);
		}
	}
	
	analogWrite(pinLED, 0);

}

void HALwaits ()
{
	// Make the button LED pulse as if it were talking
	int attackTime = 500;
	int fadeTime = 500;
	
	unsigned long startTime = millis();
	

	// ramp LED up
	for (int i = 0; i<attackTime; i++)
	{
		int j = map(i, 0, attackTime, 0, 120);
		analogWrite(pinLED, j);
		OneSheeld.delay(1);
	}
	
	// ramp LED down
	for (int i = fadeTime; i>0; i--)
	{
		int j = map(i, 0, fadeTime, 0, 120);
		analogWrite(pinLED, j);
		OneSheeld.delay(1);
	}

	
	//HAL fades out
	analogWrite(pinLED, 0);
	
}

void loop()
{
	if (OneSheeld.isAppConnected())
	{
		if (!isConnected){
			isConnected = true;
			OneSheeld.delay(5000);
			action();
		}
	}
	else
	{
		isConnected = false;
		HALwaits();
	}
}

Hospitality Hal

Welcoming robot for the MakerHive using OneSheeld

Credits

Michael Sizemore

Michael Sizemore

1 project • 3 followers
Engineer, Maker

Comments