0

trigger sound board with IR arduino?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

trigger sound board with IR arduino?

by JRL on Wed Nov 06, 2019 2:18 pm

Bought the Adafruit Audio FX Sound Board + 2x2W Amp. Works great, created a bunch of ogg sound files. No problem.
Triggers by buttons, works great - but I don't want buttons, I want IR. (infra red remote control)

Got the IR code working with Arduino - can trigger an LED to turn on and off with remote IR. You put the Hex number into the code: Pretty cool. It works

But on and off does not trigger the sound card. The sound card pins are triggered by 'go to ground' not on and off. Godamnit!

Does anyone know how to do this? Not finding much documentation. Not an expert at Arduino coding (not an expert at anything, really, except maybe CNC coding. I'm an old machinist who grew up before the age of computers)

Thank you for any help.

PS: if I get it working will post the Arduino code for others trying to do the same thing) = push a remote IR button, trigger a sound file.

JRL
 
Posts: 12
Joined: Mon Jul 08, 2019 9:25 pm

Re: trigger sound board with IR arduino?

by mikeysklar on Wed Nov 06, 2019 3:07 pm

Hi JRL,

Trying to imitate a button press directly with the IR remote is not going to work.

How about if we receive the IR signal
Interpret the IR character eg. 1, 2, 3, 4...
Pull a pin low (eg. pin1 = 0)
wait the required 120ms to 200ms
set the pin high again (eg. pin1 = 1)

If you want to get fancier than that there is serial based audio control:

https://learn.adafruit.com/adafruit-aud ... io-control

mikeysklar
 
Posts: 346
Joined: Mon Aug 01, 2016 8:10 pm

Re: trigger sound board with IR arduino?

by JRL on Wed Nov 06, 2019 11:30 pm

Yeah, I already tried that and it works - turn the power on to a pin, then turn the power OFF and the sound card is triggered = go to ground.

Here's the problem with that - I'm sending a 5 volt signal TO the sound card pin. It made a funny noise when I did that, and I thought oh no! Did I just roast my sound card?

Nope, the sound card is okay. But it worried me.

The other thing is, when you turn the power off and trigger the sound card, it keeps recycling the same file without being triggered. In other words, the pin continues to be grounded.

The sound card can be controlled by Arduino and the remote works with Arduino so it seems to me this is a simple matter of coding ( if this then do that).

Not giving up.

Thanks for the reply.

JRL
 
Posts: 12
Joined: Mon Jul 08, 2019 9:25 pm

Re: trigger sound board with IR arduino?

by kcl1s on Thu Nov 07, 2019 8:13 am

Here's the problem with that - I'm sending a 5 volt signal TO the sound card pin. It made a funny noise when I did that, and I thought oh no!

Are the GNDs of the Arduino and the sound board connected together? They need to be.

The other thing is, when you turn the power off and trigger the sound card, it keeps recycling the same file without being triggered. In other words, the pin continues to be grounded.

The code mikeysklar provided to pulse the pin low for 200 ms will help this.

The sound card can be controlled by Arduino and the remote works with Arduino so it seems to me this is a simple matter of coding ( if this then do that).

Yes it is. Start with one IR button press and one trigger to the soundboard. If you run into trouble and can not get it to work post photos of your wiring and post your code efforts (please place the code between the code tags available on the bar above the text entry area)

Fellow hobbyist
Keith

kcl1s
 
Posts: 1332
Joined: Tue Aug 30, 2016 12:06 pm

Re: trigger sound board with IR arduino?

by JRL on Sat Nov 09, 2019 7:41 pm

The solution is to use a transistor to block the ground by shutting it off. I'm using 2N2222 because I got a bunch of them.

So the IR trigger (I'm using pin 12) from Arduino goes to the middle pin (base) on the transistor.

The trigger from whatever pin on the sound board you want to activate goes to the emitter on the transistor. The collector on the transistor goes to ground.

digitalWrite(12, HIGH); break; will initialize the transistor to let current flow and trigger whatever pin on the sound board it is connected to.
Wait a fraction of a second (or whatever time interval you want) and write a:
digitalWrite(12, LOW); break; to shut the transistor off.

This blocks the sound board from ground and prevents the sound board from repeating the track.

I have to use a transistor for each pin on the sound board but that's okay, they're super cheap and I got a bunch.

In this way I can use all the pins on the sound board and initialize each one separately with the IR remote.

For anyone who is interested.

Thanks again!

JRL
 
Posts: 12
Joined: Mon Jul 08, 2019 9:25 pm

Re: trigger sound board with IR arduino?

by mikeysklar on Sun Nov 10, 2019 6:30 pm

Thanks JRL for the elegant solution / summary update. Much appreciated.

mikeysklar
 
Posts: 346
Joined: Mon Aug 01, 2016 8:10 pm

Re: trigger sound board with IR arduino?

by JRL on Mon Nov 11, 2019 1:36 am

mikeysklar wrote:Thanks JRL for the elegant solution / summary update. Much appreciated.


Most welcome. I'm sure there must be a more elegant solution in coding but I don't know much about it and I couldn't find any documentation. Luckily I do know how to use a 25 cent transistor as a switch.

Problem is when you simply power down the pin on arduino it remains grounded and the sound board is triggered by grounding so it just keeps triggering the same pin! A push button solves this by removing ground when you release the button. But I wanted to use IR remote.

The arduino code for the IR remote is very simple and I will post it if anyone is interested - works perfectly!

Take care...

JRL
 
Posts: 12
Joined: Mon Jul 08, 2019 9:25 pm

Re: trigger sound board with IR arduino?

by JRL on Wed Nov 13, 2019 1:51 am

Correction: I inadvertently flipped the transistor the wrong way around. It will work the wrong way around, but here is the correct pinout.

https://www.componentsinfo.com/2n2222-t ... quivalent/

Also suggest using a resistor from the arduino to trigger the middle pin (base) I'm using 330 ohms. Even at 5 volts you could damage the thing and it takes very little current to trigger the transistor.

Here's the simple sketch I used to trigger arduino with IR remote - only two buttons (one trigger/one on-off). As I start adding the rest of the buttons it will get too complicated.

You can use any old remote you got laying around and re-purpose it for this. Upload the sketch and run the serial monitor. When the buttons on the remote are pressed, copy the hex number that will appear and insert them into the code! You gotta stick an 0x in front for some reason - like this: case 0xFF6897 (see where I put them in the code below)

Don't ask me why, cause I don't know. But happy to help anyone having problems. Hey if I can do it anybody could.

The sound board works real good with this little setup and you can fire off all 10 sound files individually with a remote button push.

That's it!


*/

// Include IR Remote Library by Ken Shirriff
#include <IRremote.h>

// Define sensor pin
const int RECV_PIN = 13;

// Define LED pin constants
const int Pin3 = 3;
const int Pin4 = 4;

// Define integer to remember toggle state
int togglestate = 0;

// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;


void setup(){
// Enable the IR Receiver
irrecv.enableIRIn();
// Set LED pins as Outputs
pinMode(Pin3, OUTPUT);
pinMode(Pin4, OUTPUT);
}


void loop(){
if (irrecv.decode(&results)){

switch(results.value){
case 0xFF6897: //Keypad Button 0
// Turn on LED for 2 Seconds
digitalWrite(Pin3, HIGH);
delay(2000);
digitalWrite(Pin3, LOW);
break;

case 0xFFA25D: //Keypad Button Power On
// Toggle LED On or Off
if(togglestate==0){
digitalWrite(Pin4, HIGH);
togglestate=1;
}
else {
digitalWrite(Pin4, LOW);
togglestate=0;
}
break;

}
irrecv.resume();
}

}

JRL
 
Posts: 12
Joined: Mon Jul 08, 2019 9:25 pm

Re: trigger sound board with IR arduino?

by mikeysklar on Wed Nov 13, 2019 5:30 pm

Excellent. Thank you for the share.

mikeysklar
 
Posts: 346
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.