Sex Panther Prop guidance

Hi all,

been lurking around for a while, and I'm almost on the cusp of being on the downhill slope side of a project I've been working on (during scattered spare time when my wife and young kids are finally asleep)
I've been VERY slowly trying to build an Anchorman Sex Panther prop and have most of the internals figured out - even to the point of almost being ready for the final install.

For those who don't know what I'm talking about:

Sex Panther cologne display box and panther head as shown in the movie Anchorman
Sex Panther movie clip

Anyway, I've already built the scissor lift, have a replica panther head already modded for the cologne. And believe it or not, they actually do sell a cologne called Sex Panther which... surprisingly doesn't smell like BigFoot's ****. :stuck_out_tongue:

Originally I set up the Arduino to work with two momentary switches. Press one, and it activates an MP3 player to play the panther growl, the platform lifts up, and one of the movie quotes plays after a slight delay. Press the other momentary button, and the platform drops and a final MP3 file plays.

However, I recently realized a solution to the box lifting lid - best switch to use would be a roller lever switch like this (which kinda incorporates a normally open and a normally closed switch into the same device).

The way I was envisioning this to work is that there are little arms in the lid hinge. When the lid is closed, the switch would be depressed. When the lid is open, then it releases pressure on the roller switch and the switch also therefore opens. When I went to test the switch with the circuit, though, it didn't seem to work. I can only think that because it's almost acting more like a latching switch than a momentary switch, it's causing a feedback loop that is interfering with the way I had originally written the code.

Here is my code so far:

//cannibal869 servo and dfplayer test code
// Powering a servo from the arduino usually *DOES NOT WORK*.
//   DFPlayer prefers around 4Vf
//   note: mp3 file must put into mp3 folder in your tf card


#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup () {
 Serial.begin (9600);
  mp3_set_serial (Serial); //set Serial for DFPlayer-mini mp3 module 
  mp3_set_volume (25);          // 15 is low for unpowered speaker 
                                      // 30 good for unpowered speaker - requires power off to reset volume
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    mp3_stop ();
    delay (2000);
    mp3_play (1);
    delay (2000);
    servo1.write(143);
    delay (6000);
    mp3_play (2);
  }    
  
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    mp3_stop ();
    servo1.write(62);
    delay (3000);
    mp3_play (3);
  }
}

/*
   mp3_play ();   //start play
   mp3_play (1);  //play "mp3/0001.mp3"
   mp3_next ();   //play next 
   mp3_prev ();   //play previous
   mp3_set_volume (uint16_t volume);  //0~30
   mp3_set_EQ (); //0~5
   mp3_pause ();
   mp3_stop ();
   void mp3_get_state ();   //send get state command
   void mp3_get_volume (); 
   void mp3_get_u_sum (); 
   void mp3_get_tf_sum (); 
   void mp3_get_flash_sum (); 
   void mp3_get_tf_current (); 
   void mp3_get_u_current (); 
   void mp3_get_flash_current (); 
   void mp3_single_loop (boolean state);  //set single loop 
   void mp3_DAC (boolean state); 
   void mp3_random_play (); 
 */

I saw another thread here talking about maybe using a State Change detection and I attempted to combine that into the current code, but I am likely way out of my depths here (I'm probably much more of a machinist than coder/programmer). So I'm asking for the Arduino Gods here to help.... please?

Ideally, I'd like a few things to happen:
1). start the servo at the fully closed setting once power is turned on to the board.
2). be able to have it sit idle doing nothing until the lid is opened - then go through the above steps (play growl, raise platform, play 2nd music file).
3). then remain idle with the platform raised until it detects the lid closing. Then go through the second set of steps to lower the platform and play the final music file after the indicated delay. And then go back to step 2 and wait...

it sounds so easy in concept, but not quite so much in practice, lol...

thank you all in advance for any guidance or sample code you can offer me. I truly appreciate it... especially seeing as how this gift is already 2 years overdue!

-Chris

  1. Change your quote tags to code tags.

  2. Read about state machines here: State Machine

Try to draw the state diagram. Instead of using delays, think about having it check the millis timer to see if it's time to do the next action. It can also check the switches and other inputs during that time. Depending on what state you're in (eg. playing sound #1) then pressing or releasing a switch may jump to a different state. (Usually you would call mp3_stop() before going to that state.)

cannibal869:
I can only think that because it's almost acting more like a latching switch than a momentary switch, it's causing a feedback loop that is interfering with the way I had originally written the code.

Those micro-switches are latching switches - that's what "normally open" means.

I have not looked at your code but my guess is that you need to detect when the switch changes rather than whether it is open or closed.

...R

cannibal869:
When I went to test the switch with the circuit, though, it didn't seem to work. I can only think that because it's almost acting more like a latching switch than a momentary switch, it's causing a feedback loop that is interfering with the way I had originally written the code.

You did use the C terminal as one of your wiring points, yes?

MorganS:

  1. Change your quote tags to code tags.

  2. Read about state machines here: State Machine

Try to draw the state diagram. Instead of using delays, think about having it check the millis timer to see if it's time to do the next action. It can also check the switches and other inputs during that time. Depending on what state you're in (eg. playing sound #1) then pressing or releasing a switch may jump to a different state. (Usually you would call mp3_stop() before going to that state.)

thanks for all the advice everyone - sorry I'm a NOOB at this.
State Machines does sound like the way to go - I'll try to look at that sometime this weekend.
-C

Robin2:
Those micro-switches are latching switches - that's what "normally open" means.

Not right this time. Latching means that the same method of actuation changes the on/off state, and that state is retained. Like a push-on push-off.

aarg:
Not right this time. Latching means that the same method of actuation changes the on/off state, and that state is retained. Like a push-on push-off.

Indeed. You are quite correct. And I humbly apologise to all.

What I should have said was that they are not momentary contact switches. I guess I got carried away responding to the sense in which the OP used the word latching

I can only think that because it's almost acting more like a latching switch than a momentary switch,

Is there a word that describes a non-momentary contact switch without describing what it is not?

...R

The switch in post #1 is a momentary, like your doorbell. Your kitchen light switch which stays in one of two positions is a *maintained * switch