the demo video:
We all know Gamera, kaiju guardian of the universe and protector of children.
This Halloween inspired hat emulates Gamera flying, spinning on a turntable, radioactive flame jets firing from the shell's arm and leg holes.
A magnet inside Gamera is read by a Hall effect sensor.
As the magnet passes the sensor, the Arduino is counting rotations.
On a random # of rotations, Gamera will pause spinning with his head facing forward (home position) and roar.
After the roar, it will return to the spinning condition.
- Gamera's head is 3D printed.
- The body sides are cardboard with a foam covering, mounted on a plastic sheet. The sheet has holes in the center for bolting down Gamera's body to the gearmotor coupling.
- The hat has separate power switches for the turntable, and another for Gamera's flames.
- The turntable also has a hidden but easily accessible N.O. pushbutton to start/stop turntable rotation.
- Gamera's roar is saved to a ISD1820PY board. The 1820 has a speaker output, so I used a hi bandwith balun as an audio isolation transformer to the LM386 audio amp since the amplifier module is expecting a DAC input grounded on one side.
- Since the turntable doesnt reverse direction, rather than connect an H bridge to the Arduino, a single MOSFET is used,
which still can provide PWM speed control if desired.
- Code and schematics attached
/*
GameraArduinoTurntable.ino
debugging code is left in, but commented out
*/
int HomeSwitch=LOW;
int HomeSwitchOS = LOW;
int HomeSwitchLastScan=LOW;
int TurntableMotorON = LOW;
int TurntablePausePB = HIGH;
int TurntablePausePBLastScan = HIGH;
int HomeSwitchCnts =0;
int HomeSwitchCntsTarget =0; // # of counts to accumulate before autopause the turntable
int AutoPause= LOW;
void setup() {
//start serial connection
// Serial.begin(9600);
//configure pin 2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP); //Pause spin pushbutton
pinMode(4, INPUT); //Home position hall ellect switch
pinMode(8, OUTPUT); // play audio output
pinMode(11, OUTPUT); // turntable motor ON
pinMode(13, OUTPUT);
randomSeed(analogRead(0));
}
void loop() {
//read the pushbutton value into a variable
TurntablePausePB = digitalRead(2); // HIGH is PB not pressed
HomeSwitch = digitalRead(4); // HIGH is home switch active
// THIS IS THE TURNTABLE AUTOPAUSE CODE BASED ON A RANDOM number of spins
if ((HomeSwitch == HIGH) && (HomeSwitchLastScan== LOW))
{
HomeSwitchOS == HIGH;
HomeSwitchCnts = HomeSwitchCnts + 1;
}
else
{
(HomeSwitchOS == LOW);
}
// if (HomeSwitchOS==HIGH)
// { HomeSwitchCnts = HomeSwitchCnts + 1;} // counting Homeswitch passes
delay (10); // catch up
// Serial.print(" HomeSwitch == ");
// Serial.print(HomeSwitch);
// Serial.println ();
// Serial.print(" HomeSwitchLastScan ");
// Serial.print(HomeSwitchLastScan);
// Serial.println ();
// Serial.print(" HomeSwitchCnts = ");
// Serial.print(HomeSwitchCnts);
// Serial.println ();
HomeSwitchCntsTarget=random(5,40);
if (HomeSwitchCntsTarget<HomeSwitchCnts)
{ AutoPause=HIGH; }
else { AutoPause=LOW;}
// Serial.print(" HomeSwitchCntsTarget = ");
// Serial.print(HomeSwitchCntsTarget);
// Serial.println ();
delay (10);
// DONT FORGET TO ADD CODE TO RESET HOMESWITCH CONTER , add code to stop on counts
// TURNTABLE CONTROL CODE ///
if ((TurntablePausePB == HIGH) && (TurntablePausePBLastScan==LOW)&& (TurntableMotorON == LOW)) //means PB was pressed, run the turntable motor
{ TurntableMotorON = HIGH;
TurntablePausePBLastScan=TurntablePausePB;
delay (100); // debounce
}
if ((TurntablePausePB == HIGH) && (TurntablePausePBLastScan==LOW)&& (TurntableMotorON == HIGH)) //means PB was pressed while running, stop the turntable motor
{ TurntableMotorON = LOW;
// TurntablePausePBLastScan=TurntablePausePB;
delay (100); //debounce
}
digitalWrite(8,AutoPause); // turn on output to trigger soundplayer
digitalWrite (13,AutoPause);
if ((TurntableMotorON == HIGH)&&(AutoPause==LOW))
{
digitalWrite(11, HIGH);
}
else { digitalWrite(11, LOW); // pause turntable for 10 secs, play audio , zero home switch counts
if (AutoPause==HIGH)
{ delay (7000);
HomeSwitchCnts=0;
AutoPause=LOW; }
}
//Serial.print(" TurntablePausePB = ");
//Serial.print(TurntablePausePB);
// Serial.println ();
//Serial.print(" TurntablePausePBLastScan = ");
// Serial.print(TurntablePausePBLastScan);
// Serial.println ();
// Serial.print(" TurntableMotorON = ");
//Serial.print(TurntableMotorON);
// Serial.println ();
// Serial.print("AutoPause = ");
// Serial.print(AutoPause);
// Serial.println ();
// digitalWrite (13,TurntableMotorON);
TurntablePausePBLastScan=TurntablePausePB;
HomeSwitchLastScan=HomeSwitch; // update last scan status
}
Here are some of the progress pix while building the Gamera hat and testing HW & SW.
I really really appreciated using the nice test equipment won in previous E14 project competitions.