Sending "low" signal to Adafruit Sound Board from Uno IO

Hi all.

I'm trying to get a LOW output signal from the Uno to trigger a sound effect on the Adafruit sound board. The board needs to have the pin connected to ground in order to trigger. With all grounds being the same, is sending a LOW (0V) signal directly to the pin the same as connecting it to the ground(- end of the DC)?

Here is my code:


int triggerpin = 10; //set the output of Pin 10 on the A to the Trigger of the Sensor
int echopin = 11; //set the input of the echo from the sensor to pin 11.
int PlaySound = 12; //set the output to the soundcard to Pin 12
long Duration; //sets variable for echo time measurement
long Distance; //Sets a variable for Distance Measurement
int DoorClosed; //sets/checks status of door being open or closed; 1 is closed


void setup() {
  pinMode(triggerpin, OUTPUT); //sets triggerpin to output
  pinMode(echopin, INPUT); // sets echopin to input
  pinMode(PlaySound, OUTPUT);  //sets PlaySound to output
  Serial.begin(9600);
  DoorClosed = 1;
  digitalWrite(PlaySound, HIGH); //sets the sound trigger to HIGH (off)
}

void loop() {
  digitalWrite(triggerpin, LOW);
  delayMicroseconds(2); //wait 2 uS
  digitalWrite(triggerpin, HIGH); //sets triggerpin to HIGH, starts the ball rolling
  delayMicroseconds(10); //wait 10 uS
  Duration = pulseIn(echopin, HIGH); //high triggered when sensor hears the echo back
  Distance = (Duration / 2) * 0.014; //multiply one-way duration by the speed of sound in inches per microsecond,
  Serial.println(Distance);  //displays the distance on the readout.
  //Distance is distance in inches

  if (Distance < 5) { //sets the position of the door
    DoorClosed = 1;
  }
  else
  {
    DoorClosed = 0;
  }

  if (Distance > 4 && DoorClosed == 1 ) {
    digitalWrite(PlaySound, LOW); // send a LOW signal to the sound card, triggering the SFX.
    delay(250);  //wait .25 seconds, timing is milliseconds
    digitalWrite(PlaySound, HIGH);  //resets to HIGH to only play the sound once.
  }
  else
  {
    Serial.println(PlaySound);
    Serial.println( "No change in door position" ); //reports status of door, back to top.        }
  }

}

When I'm looking at the output on the monitor, it does everything I'm asking it to do, but the sound card doesn't see the output as being connected to ground. What more do I need?

Thanks!

Jeff

Welcome to the forum

How exactly is the sound board connected to the Uno ?
Where does it get its power from ?

1 Like

The sound board is connected to the Uno just on 1 pin. Both are getting their power from the same 3.5V battery.

The connection between the Uno and the Ada is only on Pin 12 of the Uno (set to output) and Pin 1 of the Adafruit.

Interesting thing I just discovered: If I unplug the Uno from the power source and leave Pin 12 connected to Pin 1 of the Ada, it plays the SFX non-stop.

So, I figured it out.

This line
if (Distance > 4 && DoorClosed == 1 ) {
was never being seen as true.

a simple fix to change it to
if (DoorClosed == 0)
and the addition of a variable "DidTheThing", which could only be reset if DoorClosed ==1, did the thing I needed it to do.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.