Build a MOTION Activated MP3 Player with Arduino and PIR Sensor - Easy DIY Guide!

Поделиться
HTML-код
  • Опубликовано: 7 янв 2025
  • НаукаНаука

Комментарии • 12

  • @SlickDiecast
    @SlickDiecast Месяц назад

    Thanks for showing this setup. In my previous project, I used a DF mini player and was able to power it through the Arduino Uno. The only issue was, I used a 3W speaker and was not loud enough when there were a lot of people around and talking.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Месяц назад

      I like the DFplayer but I need to use an amplifier with it. This was has an onboard amp that's plenty loud, at least for my 8ohm speaker. It sounds way better with my bluetooth speaker though. I really like this mp3 board 👍
      Thanks for leaving a comment!

  • @rlrentertainmentsinventions
    @rlrentertainmentsinventions Месяц назад +2

    Good explanation bro

    • @BMonsterLaboratory
      @BMonsterLaboratory  Месяц назад +1

      Thanks for checking it out! I'm glad you found it helpful! 👍

    • @rlrentertainmentsinventions
      @rlrentertainmentsinventions Месяц назад +1

      @@BMonsterLaboratory it's ok bro

    • @jurrasicbrick3256
      @jurrasicbrick3256 Месяц назад +1

      Hello bro, your video is very good. I don't know if you can make a video where you use the PCA 9685 module in bottango. Maybe in case an Arduino code is needed so that it later works in bottango and about the storage of the animations that are made in bottango because I think which has a very low limit and I would like at least a 3 minute animation to be saved​@@BMonsterLaboratory

    • @BMonsterLaboratory
      @BMonsterLaboratory  Месяц назад

      Hi, thank you.
      I could revisit bottango but it may be a while. Did you check out this video where I used the PCA9685 module ? ruclips.net/video/DWvVfzULl6U/видео.html

  • @SlickDiecast
    @SlickDiecast Месяц назад

    I’m starting to notice that my Arduino project is getting bigger and more components are being added. Each requiring a separate power source. How could you run all the components off one power supply? I’ve seen other creators use a single power supply with splitters, along with buck converters. Will this be a good solution for bigger projects that require more power supplies?

    • @BMonsterLaboratory
      @BMonsterLaboratory  Месяц назад

      Yes, that's a good idea. I have a IMAYCC 0-24V Adjustable Power Supply. It does an excellent job of supply enough power for multiple projects. Split the various converters and your problem is solved. If you get a buck convert, be sure to get one rated above the current you need. They typically operate at 85-90% efficiency. I like to leave 20% headroom for current so I don't overheat. I hope that helps 👍

  • @cookieburns4552
    @cookieburns4552 Месяц назад +1

    How can I get the code?

    • @BMonsterLaboratory
      @BMonsterLaboratory  Месяц назад +1

      I post it all on Facebook. It doesn't always fit in the video description but this one is short. Here it is! 👍
      #include
      SoftwareSerial mp3Serial(10, 11); // rx, tx for mp3 module
      const int busyPin = 12; // busy pin connected to Arduino pin 12
      const int pirPin = 3; // PIR sensor on pin 3
      const int totalTracks = 10;
      unsigned long debounceTime = 500;
      unsigned long stableEndTime = 0;
      bool motionDetected = false;
      void setup() {
      Serial.begin(9600);
      mp3Serial.begin(9600);
      pinMode(busyPin, INPUT);
      pinMode(pirPin, INPUT);
      randomSeed(analogRead(0)); // seed random for track selection
      delay(2000); // wait for mp3 module setup
      Serial.println("waiting for motion to start playback...");
      }
      void loop() {
      motionDetected = digitalRead(pirPin);
      if (motionDetected && (digitalRead(busyPin) == HIGH)) {
      int randomTrack = random(1, totalTracks + 1); // choose random track
      playSong(randomTrack);
      }
      if (motionDetected && digitalRead(busyPin) == HIGH && (millis() - stableEndTime) > debounceTime) {
      stableEndTime = millis();
      int randomTrack = random(1, totalTracks + 1);
      playSong(randomTrack);
      delay(1000); // short delay to avoid retrigger
      }
      }
      void playSong(int songNumber) {
      Serial.print("playing song number: ");
      Serial.println(songNumber);
      mp3Serial.write((uint8_t)0xAA); // start byte
      mp3Serial.write((uint8_t)0x07); // play command
      mp3Serial.write((uint8_t)0x02);
      mp3Serial.write((uint8_t)0x00);
      mp3Serial.write((uint8_t)songNumber);
      mp3Serial.write((uint8_t)((0xAA + 0x07 + 0x02 + 0x00 + songNumber) & 0xFF));
      delay(1000); // ignore busy pin during first second of playback
      }

    • @cookieburns4552
      @cookieburns4552 Месяц назад

      @BMonsterLaboratory thanks, much appreciated.