Df mini player with atmega32

Hi Everyone
I wanted to play DF mini player with ATmega32 But , DF mini player is not play

Please suggest me

DF mini player to ATmega32 Pin connection with speaker

code

#include <mega32.h>
#include <delay.h>

// UART send function
void UART_Send(unsigned char data) {
    while (!(UCSRA & (1 << UDRE))); // Wait for empty transmit buffer
    UDR = data;  // Send data
}

// DFPlayer Mini Send Command
void DF_Send(unsigned char command, unsigned char param1, unsigned char param2) {
    unsigned char checksum = 0xFF + 0x06 + command + 0x00 + param1 + param2;
    
    UART_Send(0x7E); // Start byte
    UART_Send(0xFF); // Version
    UART_Send(0x06); // Length
    UART_Send(command);
    UART_Send(0x00); // Feedback (0 = no feedback)
    UART_Send(param1);
    UART_Send(param2);
    UART_Send((~checksum) & 0xFF); // Checksum
    UART_Send(0xEF); // End byte
    
    delay_ms(500); // Small delay for stability
}

void main() {
    UCSRB = (1 << TXEN) | (1 << RXEN); // Enable TX and RX
    UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0); // 8-bit data
    UBRRL = 51; // 9600 baud @ 8MHz

    delay_ms(1000); // Wait for DFPlayer to initialize

    DF_Send(0x3F, 0x00, 0x00); // Reset DFPlayer
    delay_ms(2000);

    DF_Send(0x06, 0x00, 0x1E); // Set volume (0x1E = 30)
    delay_ms(500);

    DF_Send(0x12, 0x00, 0x01); // Play track 1

    while (1);
}

I moved your topic to an appropriate forum category @vishwjeet123

In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Why did you choose to not use the Arduino IDE setup() and loop() code?

Last time I ran DFPlayer Mini (project interrupted by COVID and moving house, code ... better to use what is forum-archived here) I used Arduino IDE setup() and loop() with Serial to Serial Monitor interface and software serial to the player. That let me read the messages the player sent back and not need esoteric means to access the player.

There is a library according to links I saw in a web search.

There are docs for the player including how to run it stand-alone with buttons and what buttons can do, Arduino IO pins can do for simple things like you want.

Just one answer, not a complete one but it's more than you have.

I dunno why you chose to go the route you did. Maybe that's what you're used to or maybe it's what you found on the net. The difference means a lot as to what you do now.

I Run DF mini player Arduino also, here is run smoothly but i make a project on Atmega32 and wanted to add DF mini player on ATmega32 DF mini player didn't play

It is possible to program a standalone ATmega32 with Arduino IDE if you bootload it or use ISCP pins, not that you have to but if you do then you can use your code that runs smoothly with changes for pin numbers.

This could save a lot of dev time...
DFplayer updated library in 2017 thread.

I am using Code Vision AVR as a compiler, and my microcontroller is ATmega32. I don't want to use Arduino as a programmer because I am using a USBasp programmer for ATmega32.

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