How to use Arduino to sequence outputs in order

I'm very new to Arduino, and hope it can do what I need here.

My project receives a GND signal from a Field Disturbance Sensor (lets you know when someone comes to close), and each time this GND signal is received I need to trigger a GND output to an MP3 player in sequence (1-6). So first signal activates #1, second time it activates #2, and so on. After #6 it starts back at 1 again. Final product will play a different sound each time the sensor is activated.

Can this be done, and if so, any help on programming is appreciated! Thanks!!

Can you write a sketch that just plays the same track every time you press a button?

Then use the signal to do what the pushbutton does.

Add a counter you can rest when it gets to 6; the signal should play the track number that is the counter as it goes 0 .. 5. Or 1 to 6 if you have not yet consumed the zero is a perfectly number koolaid.

So in that way for one yes, you can get what you need to happen.

a7

1 Like

No it has to be completely autonomous - no pushing buttons. When someone approaches, the sensor will be activated, and I want the output to rotate through 6 different responses in order. Make sense?

I should have explained that you could proceed using a pushbutton to make the sketches I proposed, get it working in stages until a pushbutton can do what you want the sesnor to do eventually.

Apart from that, make sure your sensor is producing events that will be useful.

Now you have two sketches, just replace the use of the pushbutton level or transition or however you got that done with using the sensor level or transition in its stead.

a7

After you get the sensor working your main code would be a simple sequence.
Pseudo.
If sensor is tripped increment counter and turn on the associated device. Then wait for the next trip turn off first device and turn on second.Then wait for the next trip. When you get to the end go back to the start. You will need to You can expand all you want from this.

The DFPlayerMini has an "I/O Mode" that lets you "play next file" on the built-in-SDcard by grounding one pin. Search DFPlayerMini.

It doesn't matter. The sketch acting to the button is perfectly the same as the sketch, that do sensor monitoring. So follow the advice.

Yes, all doable. What’s the current status? Have you got the Arduino (which?), sensor, MP3 player, (I’d recommend the DFR player), speaker? Started programming your sketch?

You could get most of it done, and gain some useful experience without using an Arduino at all, as @xfpd mentioned. But you’d need the Arduino to do the simple counting logic.

EDIT
Unless you’d settle for duplicating your six tracks as many times as would fit on a 32 Gb micro SD.

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