Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Cloud with thunder effect the RGB LEDs

  1. #1
    Junior Member
    Join Date
    Aug 2018
    Location
    Dallas, TX
    Posts
    5

    Cloud with thunder effect the RGB LEDs

    Iím really not asking for code here. Iím just asking about an idea to see if Iím thinking correctly.

    I saw a Halloween project that uses a sound sensor to activate a string of pixels that have a lightning effect. I donít like the idea of the lightning being sound-activated. On Halloween, people are coming up all the time. Iíd rather it was programmed to go off randomly. Thunder, 5 second delay, then lightning.

    My thought was to use either a Teensy 3.2 or 3.6 (I have both) and mount the PJRC audio board on it, then run the audio output to a small amp.

    Does this sound reasonable? Anything Iím missing?

    Thanks,

    Mike D

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,326
    If you don't need the ultimate in sound quality or volume, a much simpler approach is to use the prop shield instead of the audio shield.

    The prop shield has the following features:
    • It has flash memory to store the thunder effect. Note, if the effect is small enough, you can put it in program memory, but often times your sound effect is larger than can fit in the available memory. The 3.6 has more memory than the 3.2, so you might be able to store the sound in the 3.6 directly. In addition, the 3.6 has a built-in micro sd-card, so you could put the sounds on the card. To use the flash memory, you would need to download files to it (there is a sketch that does this).
    • The prop shield has a built-in mono amplifier. So for a Teensy 3.2, all you have to do is connect up an small speaker. For the 3.6, you would need to run a wire from A21 (DAC1) to the back pin where A14 is on the 3.2.
    • The prop shield has built-in level shifters for the WS2812B (neopixel) or APA102 (dotstar) leds. There can be problems if you use SPI displays and want to do the pixels at the same time (you have to switch pin 11 and 13 from SPI mode to normal mode and back).
    • The more expensive of the two prop shields has a motion sensor in it, so you could activate the effect by moving it.


    Using either the prop shield or the audio shield should work. If you use WS2812B (neopixel) LEDs, if you have a lot of LEDs, it can be somewhat tricky if you are playing sounds when doing the LEDs. The WS2812B LEDs have a strict timing window, so the default libraries turn off interrupts while doing the LEDs. Unfortunately the sound system uses the interrupts to keep the music playing, so you might hear a choppy output, if the interrupts are held too long.

    If you are just playing a single effect, a simpler approach might be to get a DFPlayer (https://www.dfrobot.com/product-1121.html) which has a micro SD card, and you can use either Serial commands or pins to get it to play MP3 or WAV files. This way you don't have to do all of the sound programming in the Teensy (unless of course you want to learn how to do it). Note, the DFPlayer has been widely cloned. It may make sense to get the original one from dfrobot.com.

    I picked up a thunder .WAV file from http://www.hauntedbay.com/downloads/sounds/ many years ago, and it seems to still be there. Now, whether they legally have permission to distribute the copyrighted material (like Monster Mash, This is Halloween, Ghostbusters theme song, etc.), I dunno.
    Last edited by MichaelMeissner; 09-30-2019 at 07:19 AM.

  3. #3
    Junior Member
    Join Date
    Aug 2018
    Location
    Dallas, TX
    Posts
    5
    Thanks so very much for your generous response and providing other, simpler options. I've ordered the DF Player based on your recommendation which also, fortuitously lead me to an updated version of the project I want to do ( https://oneguyoneblog.com/2017/11/01...halloween-diy/ ). This will help a lot as I have two very similar projects, and not a lot of time. Thanks very kindly. And, in the future, for other projects, I'll look carefully at the Props Shield. - Mike Davis

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,326
    Just to be clear, I haven't used a DFPlayer in many years, and I don't recall whether I was still using an Arudino Uno or I had moved to the Teensy at that point.

    There are also flash memory based players out there. I bought a cheap one and I found it unusable since the only way to use it was to run the app from a windows system (I only use Linux). I borrowed my wife's Window system, and the app only ran in Chinese. I tried to download the files by guesswork, but it didn't work. Do NOT buy this piece of junk:


    In the past I used the Adafruit Audio FX boards, but they are kind of big. Since the prop shield came out, I haven't used the Audio FX board. The original version of the Audio FX boards with combined amplifiers had a design flaw, and Adafruit replaced some of my boards with the version with no amplifier, and I used an Adafruit stereo amplifier to connect the speakers with the later board.

    But with the Teensy 4 not having DAC's to play sound with, I've been mulling over the various options (using I2S attachments, bringing out the DFPlayer and trying it again, staying with the Teensy 3.x for sound projects, bringing the Audio FX board out of retirement, etc.):

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,326
    I was curious, and the thunder effect I mentioned that I had downloaded from Haunted Bay many years ago cannot easily be converted to the internal format to save in Teensy read-only memory. You would use the wav2sketch program included in the Teensy distribution that takes a .WAV file and converts it to a .h and .cpp file that can put as a library file. There is a Windows executable and the C source that can compile and execute on my Linux system.

    So I went to the BBC sound archive that is free for use in non-commercial settings, and downloaded a short thunder file:


    Wav2sketch produces a large file for a 6-7 second effect. It would fit in a Teensy 3.6 or 4.0, but the 3.2 does not have enough memory to hold it (165k). This would mean, you wouldn't need the prop shield, as long as you have a mono amplifier to use with the speaker.

    If you were using the prop shield, you could put it in the flash memory, but that can take some amount of work to move stuff to the flash memory.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •