Qwiic MP3 Trigger connections

My Project includes:

SPX-16282 BlackBoard C

DEV-15165 Qwiic MP3 Trigger

BOB-15931 Qwiic Button Breakout

SPX-15586 Qwiic Switch

My intent is to trigger MP3 sound files, though a group of 18 arcade style switches split into 2 smaller groups of 9

on panels on either side of a screen like on a Battleship style game |

My understanding is that 4 of these switches can be soldered directly to the MP3 Trigger, but how do I connect the other 14 switches physically ?

Option A:?

Connect two of my Arcade buttons to the BOB-15931 Button Breakout board, and one to a SPX-15586 Qwiic Switch,

and daisychain these three together, making three sets of three switches.

To look something like this:

/Button Breakout===Button Breakout===Qwiic Switch ( 3 arcade switches)

BlackBoard C==MP3 Trigger=== -Button Breakout===Button Breakout===Qwiic Switch ( 3 arcade switches)

\Button Breakout===Button Breakout===Qwiic Switch ( 3 arcade switches)

how do I connect these 9 switches to the MP3 Trigger?

Do I need to add a BOB 16784 MUX Breakout beyond the MP3 Trigger to attach the 9 switches and change each address?

Can 3 Button Breakout boards be daisy chained into a single Qwiic connection on the MUX breakout board?

Or do I need to use 2 of the BOB 16784 MUX Breakout boards, connecting 1 arcade switch to 1 port connection on the MUX individually . to make 16 connections and can use 2 solder connections on the MP3 board for a total of 18.

I would probably wire the buttons directly to the arduino (search for “arduino keypad”) and use the arduino to send play commands to the MP3 trigger over I2C, or wire the buttons to a QWIIC keypad board with the keypad removed (COM-15290) and use that to trigger the arduino if you prefer.

/mike

Thanks for the Qwiic response,(wink wink).

With having 18 switches 2 groups of 9, I would then hack 2 keypads, using the Qwiic keypads I assume I can plug into the Arduino via a Qwiic MUX breakout board TCA9548A.

Or go with the Qwiic Shield for Arduino but they show to be out of stock right now.

This would eliminate all of the little bits and pieces of Button Breakout boards and Qwiic Switches.

maybe I can return them and swap for the Keypads.

Not too hot on programming, so hoping the Qwiic system will float me through my project.

Thanks again.

Dan

Another question is:

Does the sequence of boards matter on the Qwiic system?

Meaning in which order do the boards get connected to each other.

Im assuming this:

Arduino BlackBoard c ====MUX Breakout board===Qwiic MP3Trigger ,Qwiic Keypad attached to 9 switches,Qwiic Keypad attached to second set of 9 switches.

Where as the trigger and the 2 keypads are all connected to the MUX then onto the Arduino.

I am assuming the Qwiic system sees both ways, or ALL ways via the MUX Breakout board?

Thanks

Dan

The qwiic keypad has a jumper that lets you change the address, so you can connect two of them to one quiic bus. On one, use it as is with I2C address 0x4B and on the other, solder across the address jumper ADR to change it to 0x4A. The qwiic MP3 will have address 0x37. All three can be daisy-chained on one qwiic bus so you won’t need the mux. The order won’t matter.

If the breakout board isn’t available, connect https://www.sparkfun.com/products/14425 to the arduino.

/mike

Thanks Mike;

I don’t see a Qwiic Bus , but I do find a Qwiic Multiport SPX-16906 connection, can I use this to connect them all?

This is what I am working on

attachment=0]IMG_0011.jpg[/attachment]

download/file.php?mode=view&id=5835

Thanks

Dan

You could use the Qwiic Multiport or just run jumpers from the nano to the first board, then a qwiic cable from the first to the second, etc.

/mike

Any HELP in someone writing a sample sketch to make the Qwiic Keypad and Qwiic MP3 Trigger working together?

My attempts to do this have ended with too many errors to understand and correct.

I have loaded both libraries and are able to make each board work on their own watching through the serial monitor. But unable to make the keypad call up a file on the MP3 trigger.

Just wanting a simple task of pressing a number on the keypad and playing a corresponding sound.

One more wrinkle is to use a second keypad and play additional sound on the same bus.

I understand that I can change the Address of the second keypad with solder. But it is the coding of the sketch that stumps me

Thanks for any help in advance

Dan

After many hours I was able to piece together some what of a working sketch.

I am still unable to make the second keypad function,

I soldered the ADR to make the jumper on 1 of the keypads to change address and verified it with the I2C Scanner example. It now shows to be 0x4A.

Any help in showing me how to add a second keypad to my sketch would be outstanding.

Here is my current sketch.

/*

1 BLACK Board with Qwiic connector

1 Qwiic MP3 Trigger

2 Qwiick Keypad

Object of this sketch is to use two Keypads to Trigger the MP3 files

1 keypad address normal 0x4B

1 keypad address changed to 0x4A by jumping the ADR on board

To all be used on same bus

SD card loaded with some MP3s in the root directory

Plug the Qwiic device onto an available Qwiic port

Open the serial monitor at 9600 baud

*/

#include “SparkFun_Qwiic_Keypad_Arduino_Library.h”

#include “SparkFun_Qwiic_MP3_Trigger_Arduino_Library.h” //http://librarymanager/All#SparkFun_MP3_Trigger

MP3TRIGGER mp3;

KEYPAD keypad1; //Create instance of this object

KEYPAD keypad2; //Create instance of this object

void setup(void)

{

Serial.begin(9600);

Serial.println(“Qwiic MP3 Trigger Rebel Station”);

Wire.setClock(400000); //MP3 Trigger supports higher I2C rates

if (mp3.begin(Wire) == false)

{

Serial.println(“MP3 Trigger does not appear to be connected. Please check wiring. Freezing…”);

while (1);

}

if (keypad1.begin() == false) // Note, using begin() like this will use default I2C address, 0x4B.

if (keypad2.begin(Wire, 0x4A) == false) // You can pass begin() a different address like so: keypad1.begin(Wire, 0x4A).

{

Serial.println(“Keypad does not appear to be connected. Please check wiring. Freezing…”);

while (1);

}

Serial.print("Initialized. Firmware Version: ");

Serial.println(keypad1.getVersion());

}

void loop(void)

{

keypad1.updateFIFO(); // necessary for keypad to pull button from stack to readable register

char button = keypad1.getButton();

if (button == -1)

{

Serial.println(“No keypad detected”);

delay(1000);

}

else if (button != 0)

{

if (button == ‘1’) mp3.playTrack(1); //Begin playing the first track on the SD card

if (button == ‘2’) mp3.playTrack(2);

if (button == ‘3’) mp3.playTrack(3);

if (button == ‘4’) mp3.playTrack(4);

if (button == ‘5’) mp3.playTrack(5);

if (button == ‘6’) mp3.playTrack(6);

if (button == ‘7’) mp3.playTrack(7);

if (button == ‘8’) mp3.playTrack(8);

if (button == ‘9’) mp3.playTrack(9);

if (button == ‘0’) mp3.playTrack(10);

if (button == ‘#’) Serial.println();

else if (button == ‘*’) Serial.print(" ");

else Serial.print(button);

}

delay(25); //25 could be more if needed

}

I added some tips on your other forum post.

Thank you all for helping get my project working as intended.

See viewtopic.php?f=105&t=53927

“Second keypad not triggering MP3 files” in the QWIIC SYSTEM topics.

Was able to develop a working sketch with your help.

Dan Thomspson

Happy to help out and glad those tips worked.


My project is coming along, however hit a snag in that I have programmed in some blinking LEDs, and the delays i have placed in the code seem to have an effect on the MP3 Trigger. causing the buttons not to respond to a press and that the MP3 trigger is now randomly playing sounds on it own. My buttons are ineffective.

Any suggestions that I can add to the code? or rearrange it some how?

many thanks to all who travel done this dark path with me.

Here is my code:

/*
  1 BLACK Board with Qwiic connector
  1 Qwiic MP3 Trigger 
  2 Qwiick Keypad

  Object of this sketch is to use two Keypads to Trigger the MP3 files

  1 keypad address normal 0x4B
  1 keypad address changed to 0x4A by jumping the ADR on board
  To all be used on same bus
  SD card loaded with some MP3s in the root directory
  Plug the Qwiic device onto an available Qwiic port
  Open the serial monitor at 9600 baud
*/


#include "SparkFun_Qwiic_Keypad_Arduino_Library.h"
#include "SparkFun_Qwiic_MP3_Trigger_Arduino_Library.h" //http://librarymanager/All#SparkFun_MP3_Trigger

 MP3TRIGGER mp3;

 KEYPAD keypad1; //Create instance of this object

 KEYPAD keypad2; //Create instance of this object

// Initialize the following Pins for Animation
    
    //int led8 = 8;
    //int led9 = 9;
    int led10 = 10;
    int led11 = 11;
    int led12 = 12;
    int led13 = 13;

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Qwiic MP3 Trigger Rebel Station");

  Wire.setClock(400000); //MP3 Trigger supports higher I2C rates
  
  if (mp3.begin(Wire) == false) 
   
  {
    Serial.println("MP3 Trigger does not appear to be connected. Please check wiring. Freezing...");
    while (1);
  }
  while (keypad1.begin() == false)  // Note, using begin() like this will use default I2C address, 0x4B.
  
  delay (200);
    
  while (keypad2.begin(Wire, 0x4A) == false) // You can pass begin() a different address like so: keypad1.begin(Wire, 0x4A).
  {
    Serial.println("Keypad does not appear to be connected. Please check wiring. Freezing...");
    while (1);
  }
  Serial.print("Initialized. Firmware Version: ");
  Serial.println(keypad1.getVersion());
 

  //initialize digital pin(s) led_ as an output
  //pinMode(led8, OUTPUT);
  //pinMode(led9, OUTPUT);
  pinMode(led10, OUTPUT);
  pinMode(led11, OUTPUT);
  pinMode(led12, OUTPUT);
  pinMode(led13, OUTPUT);

}
void loop(void)

{
  keypad1.updateFIFO();  // necessary for keypad to pull button from stack to readable register
  char button = keypad1.getButton();

  if (button == -1)
  {
    Serial.println("No keypad detected");
    delay(1000);
  }
  else if (button != 0)
  {
    if (button == '1') mp3.playFile(1); //Begin playing the first track on the SD card
    if (button == '2') mp3.playFile(2);
    if (button == '3') mp3.playFile(3);
    if (button == '4') mp3.playFile(4);
    if (button == '5') mp3.playFile(5);
    if (button == '6') mp3.playFile(6);
    if (button == '7') mp3.playFile(7);
    if (button == '8') mp3.playFile(8);
    if (button == '9') mp3.playFile(9);
    if (button == '0') mp3.playFile(10);
    
    if (button == '#') Serial.println();
    else if (button == '*') Serial.print(" ");
    else Serial.print(button);
 
  } 
{
  keypad2.updateFIFO();  // necessary for keypad to pull button from stack to readable register
  char button2 = keypad2.getButton();

  if (button2 == -1)
  {
    Serial.println("No keypad detected");
    delay(1000);
  }
  else if (button2 != 0)
  {
    if (button2 == '1') mp3.playFile(1); //Begin playing the first track on the SD card
    if (button2 == '2') mp3.playFile(2);
    if (button2 == '3') mp3.playFile(3);
    if (button2 == '4') mp3.playFile(4);
    if (button2 == '5') mp3.playFile(5);
    if (button2 == '6') mp3.playFile(6);
    if (button2 == '7') mp3.playFile(7);
    if (button2 == '8') mp3.playFile(8);
    if (button2 == '9') mp3.playFile(10);
    if (button2 == '0') mp3.playFile(9);
    
    if (button2 == '#') Serial.println();
    else if (button2 == '*') Serial.print(" ");
    else Serial.print(button2);
 
  } 
  delay(25); //25 is good, more is better
}

{
  
  // all led(s) power ON

  //digitalWrite(led8, HIGH);
  //delay(200);
  //digitalWrite(led9, HIGH);
  //delay(200);  
  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(200);

  //digitalWrite(led8, LOW);
  //delay(200);
  //digitalWrite(led9, LOW);
  //delay(200);
  digitalWrite(led10, LOW);
  delay(200);  
  digitalWrite(led11, LOW);
  delay(200);
  digitalWrite(led12, LOW);
  delay(200);
  digitalWrite(led13, LOW);
  delay(200);

  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(1000);
  
  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  
  digitalWrite(led11, LOW);
  delay(200);

  digitalWrite(led10, HIGH);
  delay(1000);  

  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(2000);

  digitalWrite(led12, LOW);
  delay(200);
  digitalWrite(led13, LOW);
  delay(200);

  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(200); 

  digitalWrite(led12, HIGH);
  delay(2000);
  
  digitalWrite(led11, LOW);
  delay(200);
  digitalWrite(led12, LOW);
  delay(200);
 
  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(200);

  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(200);

  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(200);

  digitalWrite(led11, LOW);
  delay(200);
  digitalWrite(led12, LOW);
  delay(200);

  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(2000);

  digitalWrite(led10, LOW);
  delay(200);  

  digitalWrite(led10, LOW);
  delay(200);  
  digitalWrite(led11, LOW);
  delay(200);
  digitalWrite(led12, LOW);
  delay(200);
  digitalWrite(led13, LOW);
  delay(200);

  //digitalWrite(led8, HIGH);
  //delay(200);
  //digitalWrite(led9, HIGH);
  //delay(200);  
  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(2000);

  digitalWrite(led13, LOW);
  delay(200);

  //digitalWrite(led8, LOW);
  //delay(200);
  //digitalWrite(led9, LOW);
  //delay(200);
  digitalWrite(led10, LOW);
  delay(200);

  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(2000);

  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(2000);

  digitalWrite(led13, HIGH);
  delay(200); 

  digitalWrite(led12, HIGH);
  delay(2000);
  
  digitalWrite(led11, LOW);
  delay(200);

  digitalWrite(led10, LOW);
  delay(200);  
  digitalWrite(led11, LOW);
  delay(200);
  digitalWrite(led12, LOW);
  delay(200);

  digitalWrite(led10, HIGH);
  delay(200);  
  digitalWrite(led11, HIGH);
  delay(200);
  digitalWrite(led12, HIGH);
  delay(200);
  digitalWrite(led13, HIGH);
  delay(2000);
}

}
/code]

Unfortunately, it’s been a while since I last read this post. Cool rig, by the way!

If I had to guess off the top of my head, the code is running your LEDs, when you expect the code to be also reading the button presses. You’ll need to utilize an interrupt for the keypad (so the button presses trigger an interrupt in the currently operating process).

Your LED code is full of delay() calls. These calls are blocking; while you are waiting for the delay to time out, nothing else happens. So your LED routines tie things up for many seconds and you don’t look at the keypad during that time.

Two fixes come to mind:

As Santa_Impersonator said, you could tie the INT line from the keypad back to the processor and have it interrupt when a key is pressed. The interrupt service routine could then send a message to play the track.

Alternatively, you could create a state machine so that your main loop executes once every 200ms, and you keep track of where you are in the LED pattern to decide what to do next. Each pass through the main loop would also check the keypad as you are doing now.

/mike

Thanks guys for responding. I have added to sketch but no effect yet.

const byte keypad1InterruptPin = 2; // Connect to the INT pin on Qwiic keypad1
 const byte keypad2InterruptPin = 3; // Connect to the INT pin on Qwiic keypad2/code]

and under Void Setup:
[code]void setup(void)
{
  pinMode(keypad1InterruptPin, INPUT_PULLUP);
  pinMode(keypad2InterruptPin, INPUT_PULLUP);/code]

and under Void Loop:
[code]void loop(void)

{
  if (digitalRead(keypad1InterruptPin) == LOW)
  if (digitalRead(keypad2InterruptPin) == LOW)/code]

Do I need an Interrupt command in every button press number?
Im not getting any change in button presses until it all the delays time out.

Im not sure where to place the Interrupt commands.

thanks for looking
Dan

Here is the Wiring
[attachment=0]IMG_0854.JPG[/attachment]

Here’s a basic tutorial on utilizing interrupts to help get you started: https://learn.sparkfun.com/tutorials/pr … th-arduino

Thanks Guys for responding, the interrupts sound wonderful and I now understand how they can work in my sketch. However this old dog is having troubles implementing the concepts.

Plan B:

Go with what you know…

I installed a Pro Mini to run the Led blinking routine and keep the delay mess out of the Arduino Uno .

not very efficient , but saved my sanity.

thanks again for all that contributed, and I am happy with the outcome of my project.

This build will be aired on YouTube. “The Smugglers Room” in late March, come check us out.

Haha… that seems like a great application of the KISS (keep it simple, silly) principle. Awesome, I’ll share that information with others at SparkFun.

I say the use of interrupts is more of an advanced Arduino feature/concept for most users. If you do end up going down the interrupt rabbit hole late on; you may find these tutorials on “multi-threading” useful as well:

  • - [https://create.arduino.cc/projecthub/ad ... ler-3c760b](https://create.arduino.cc/projecthub/adamb314/interrupting-thread-handler-3c760b)
  • - [https://create.arduino.cc/projecthub/ad ... uno-b8e742](https://create.arduino.cc/projecthub/adamb314/how-to-run-57-hard-real-time-threads-on-an-arduino-uno-b8e742)
  • - [https://hackaday.com/2021/03/17/running ... duino-uno/](https://hackaday.com/2021/03/17/running-57-threads-at-once-on-the-arduino-uno/)
  • Otherwise, another advance feature/concept is to use a microcontroller with multiple cores [https://www.youtube.com/watch?v=k_D_Qu0cgu8], like on the ESP32. That’s how I helped Englandsaurus get his Spotify Album Artwork Display working [https://learn.sparkfun.com/tutorials/li … rt-display]. We ran the WiFi tasks on one core and drove the display LEDs on the other core.