Close
0%
0%

sound button hack

customising a sound button to play mp3 samples you want

Similar projects worth following
I made a button say french words.

One of the first French sentences I've learned was this, when a boy was ran over by a girl on a skateboard... Let's modify a "NO!" button to play an MP3 with said sentence.


LINKS
Sounds from MP3 module: https://www.dfrobot.com/
Sounds from SPI Flash: https://learn.adafruit.com/trinket-au...
Sounds from SD card: http://elm-chan.org/works/sd8p/report...

  • 1 × No! sound button
  • 1 × Attiny85 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × DFRobot MP3 module
  • 1 × wire stuff
  • 1 × 5v boost converter (might be unnecessary)

  • Arduino code

    davedarko05/19/2018 at 07:12 0 comments

    /***************************************************
    DFPlayer - A Mini MP3 Player For Arduino
     <https://www.dfrobot.com/index.php?route=product/product&search=mp3&description=true&product_id=1121>
     
     ***************************************************
     This example shows the basic function of library for DFPlayer.
     
     Created 2014-8-28
     By [Angelo qiao](Angelo.qiao@dfrobot.com)
     
     GNU Lesser General Public License.
     See <http://www.gnu.org/licenses/> for details.
     All above must be included in any redistribution
     ****************************************************/
    
    /***********Notice and Trouble shooting***************
     1.Connection and Diagram can be found here
     <>
     2.This code is tested on Arduino Uno, Leonardo, Mega boards.
     ****************************************************/
    
    #include "Arduino.h"
    #include "SoftwareSerial.h"
    #include "DFRobotDFPlayerMini.h"
    // rx 3
    
    #include <avr/sleep.h>
    #define BODS 7                     //BOD Sleep bit in MCUCR
    #define BODSE 2                    //BOD Sleep enable bit in MCUCR
    
    #define RX    3   // *** D3, Pin 2
    #define TX    4   // *** D4, Pin 3
    
    SoftwareSerial softSerial(RX, TX); // RX, TX
    DFRobotDFPlayerMini myDFPlayer;
    void printDetail(uint8_t type, int value);
    
    void setup()
    {
      softSerial.begin(9600);
     
      
      if (!myDFPlayer.begin(softSerial)) {  //Use softwareSerial to communicate with mp3.
        
      }
      myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
      myDFPlayer.enableDAC();
      delay(200);
      myDFPlayer.volume(30);  //Set volume value. From 0 to 30
      myDFPlayer.play(1);  //Play the first mp3
    }
    
    void loop()
    {
      if (myDFPlayer.available()) {
        uint8_t type = myDFPlayer.readType();
        if (type == DFPlayerPlayFinished)
        {
          // sleep();
          // myDFPlayer.play(1);
          myDFPlayer.disableDAC();
          myDFPlayer.sleep();
          mcu_sleep();
        }
      }
    }
    
    void mcu_sleep()
    {
      byte  mcucr1, mcucr2;
    
      set_sleep_mode(SLEEP_MODE_PWR_DOWN);
      sleep_enable();
      MCUCR &= ~(_BV(ISC01) | _BV(ISC00));      //INT0 on low level
      ADCSRA &= ~_BV(ADEN);                     //disable ADC
      cli();                                    //stop interrupts to ensure the BOD timed sequence executes as required
      mcucr1 = MCUCR | _BV(BODS) | _BV(BODSE);  //turn off the brown-out detector
      mcucr2 = mcucr1 & ~_BV(BODSE);            //if the MCU does not have BOD disable capability,
      MCUCR = mcucr1;                           //  this code has no effect
      MCUCR = mcucr2;
      sleep_cpu();
    }

View project log

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates