DIY Your Own Hogwarts Sorting Hat & Make It Alexa-Enabled
Greetings, my dear aficionados of enchantment and innovation,
It is with great delight that I regale you with a tale of modern wizardry, a tale woven at a recent hackathon held by a most ingenious company. This remarkable endeavor saw the union of technology and magic, resulting in the birth of an Alexa-enabled Sorting Hat!
Allow me to illuminate the wonders that now grace this humble headwear. The Sorting Hat, once a relic of our beloved Hogwarts, has been imbued with the powers of Alexa, allowing it to perform a multitude of tasks that were once the realm of Muggle devices.
🏡 Master of the Home: The Sorting Hat, now Alexa-enabled, reigns supreme over one's abode. With a mere utterance, it commands lights, thermostats, and other smart devices to bend to its will.
🧙♂️ Guardian of Sorting Wisdom: The Sorting Hat's traditional role has been expanded to include sorting individuals into their rightful Hogwarts houses via Alexa Skills. It employs the same discerning wisdom that has served our beloved school for generations. What's more is it can play any Alexa-skill your heart so desires.
🍹 Margarita Midnight Extravaganza: Picture this, dear reader - the stroke of midnight, and with a flourish of the Sorting Hat, your dwelling transforms into a festive haven in honor of "Margarita Midnight" (from proclaimed Halloween Movie Magic in the film Practical Magic). Cocktails, laughter, and merriment abound, all at the behest of this enchanted headpiece.
The path to this extraordinary creation was paved with ingenuity and skill. The diligent minds behind this project undertook a journey that combined the arcane arts of enchantment with the precise sciences of technology.
The process involved the integration of an Arduino, the installation and configuration of the Alexa Echo Dot, and the implementation of an off-the-shelf Sorting Hat Toy. These elements, when combined with the Sorting Hat's innate magic, birthed a creation that straddles the realms of reality and wizardry.
For those eager to embark on their own odyssey of creation, our enterprising colleagues have generously shared a tutorial, providing a step-by-step guide to bring forth their marvelous creation. With a commercial Sorting Hat, an Amazon Echo device, and a sprinkle of technical prowess, you too can craft your own Alexa-enabled Sorting Hat.
May your endeavors be met with the same success and wonder that has graced this endeavor, and may your Sorting Hat serve as a beacon of innovation and magic in your own abode.
Until we meet again, may your days be filled with the enchantment of creation and the marvels of modern magic.
Yours in wonder,
Albus Dumbledore (but really, the Ghost Founder Team)
///////////////////////////////////////////////////////////////////////////////////////////
// This Arduino Sketch is to read an audio signal from Alexa and animate a Billy Bass Fish
// when it detects speech. The algorithm could easily work for Raspberry Pi if you add
// an external ADC converter. I chose Arduino because it has one built in. I like simple.
// It Measures and ADC pin and keeps a running average, deciding that reads 25 ADC units
// above average are a syllable. It stores reads in an array and recalculates average
// regularly - throwing away high readings and lowest readings as possibble errors.
// A write-up of how the hardware all works and more info can be found at
// lloydbrombach.wordpress.com
///////////////////////////////////////////////////////////////////////////////////////////
const int myADC = 0;
const int HEAD=12;
const int MOUTH=13;
const int readsCount = 12;
int min=1500;
int max=0;
int avg=analogRead(myADC);
int reads[readsCount]={0};
void setup() {
Serial.begin(9600); // setup serial
// initialize the digital pin as an output.
pinMode(13, OUTPUT); //pin out for Mouth (also LED on uno)
pinMode(12, OUTPUT); //pin out for head
pinMode(5, INPUT); //ADC IN (except maybe the pin is actually marked 0?)
dropHead();
closeMouth();
}/////////end setup()/////////////////
///////////////////////////////////////////////loop()////////////////////////////////////////////////////
void loop() {
static int i=0; //main incrementer
static int headDropCount=0;
int current = analogRead(myADC);
Serial.println(current);
///// this section updates the average audio level
///// I seem to get a better effect if I maintain both a running average
///// but also re-calculate the average regularly below
avg=avg*readsCount;
avg-=reads[i];
reads[i]=current;
avg+=reads[i];
avg=avg/readsCount;
Serial.print("avg");
Serial.println(avg);
closeMouth(); //always start closing mouth to make it look like talking
if (i++ >=readsCount)// re-calculate average and discard mins and maxes as possible noise error
{
min=1500;
max=0;
int newSum=0;
for (int j=0; j<readsCount; j++)
{
if (reads[j]<min)min=reads[j];
if (reads[j]>max)max=reads[j];
newSum+=reads[j];
}
newSum-=min;
newSum-=max;
avg=newSum/(readsCount-2);
i=0;
}
if(current>avg+25) // syllable detected, start animation
{
openMouth();
raiseHead();
delay(100); //this delay could be tweaked for effect
headDropCount=0;
}else{ //no syllable detected, start closing mouth
closeMouth();
headDropCount++;
// delay(50); //this delay could be tweaked for effect
}
if(headDropCount>65) dropHead(); //The head goes up on first syllable, but doesn't drop until interaction is complete
}
///////////end loop()//////////////
///////////animation functions below/////////////
void openMouth() {digitalWrite(MOUTH, HIGH); }
void closeMouth(){digitalWrite(MOUTH, LOW); }
void raiseHead() {digitalWrite(HEAD, HIGH); }
void dropHead(){digitalWrite(HEAD, LOW); }