E1c26033 3dfe 4809 b9ff 4f1c1c831658

invention

Virtual dad

by jdany

Published on November 28, 2015

Put the 'Wireless transmitter + Sound trigger + Arduino' circuit in dad's office. Put the 'Wireless receiver + mp3 player + speaker' circuit in kids' play room. Copy dad's message (e.g. 'Too loud!') to mp3 player. Modify the value of 'dadToleranceLevel' in the following Arduino sketch if needed:

//Pins
int xmitter = 5;
int soundsensor = A1;

//Misc
char buf[50];
int onCount = 0;

//Config
int dadToleranceLevel = 5;  //higher number == higher tolerance

void setup()
{
  Serial.begin(9600);
  pinMode(xmitter, OUTPUT);
}

void loop()
{
  int bSoundOn = digitalRead(soundsensor);

  if (bSoundOn)
  {
    onCount++;
    sprintf(buf, "sound on, cnt %d", onCount);
    if (onCount > dadToleranceLevel)
    {
      sprintf(buf, "sound still on, cnt %d", onCount);
      digitalWrite(xmitter, HIGH);
      onCount = 0;
    }
  }
  else
  {
    sprintf(buf, "sound off");
    analogWrite(xmitter, 0);
    onCount = 0;
  }

  Serial.println(buf);
  delay(1000);  
}
{code}


Duration: 1 hr

Related Projects

Roll the Tape #ChainReaction

When we press the button, a servo makes the stick hit a marble that hits the roll of tape. The tape rolls down and drops a block ...

Fishing Game

A game resembling a toy from decades past in which fish are pulled out of a wind-up rotating pond with a magnetic fishing pole. &n...

Bits on a string part 4

Episode 4 of the continuing story of the Dulcimer powered by Littlebits.See episode 1 for the making of the 3-string dulcimer that...