Codey OnlineBiblioteka komponentów Arduino i ESP32 › 3W amplifier MAX98357A I2S DAC
3W amplifier MAX98357A I2S DAC
Wyjście

3W amplifier MAX98357A I2S DAC

Moduł wzmacniacza mono Class-D MAX98357A I2S (3W). Odbiera cyfrowy dźwięk I2S i bezpośrednio napędza głośnik. Nie wymaga DAC — wejście cyfrowe, wyjście analogowe po wzmocnieniu.

Protokoły: I2S Szerokość: 17.9 mm

Pinout — 3W amplifier MAX98357A I2S DAC

Pin Sygnał Opis
SPK - audio Speaker - out
SPK + audio speaker + out
LRC data bottom header far-left hole
BCLK SCK bottom header left hole
DIN data bottom header center-left hole
GAIN digital bottom header center hole
SD data bottom header center-right hole
GND ground bottom header right-center hole
VIN power bottom header far-right hole

Wskazówki dotyczące połączeń

Piny wejścia I2S: BCLK (bit clock), LRC (word select / LRCLK), DIN (dane szeregowe). Zasilanie: VIN (3.3V-5V), GND. Wyjście głośnikowe: podłącz SPK+ i SPK- bezpośrednio do pasywnego głośnika (4-8 ohm, do 3W). ZAWSZE uwzględniaj połączenie głośnika na schematach okablowania — bez niego wzmacniacz jest bezużyteczny. Pin GAIN: pozostaw niepodłączony dla 9dB, podłącz do GND dla 12dB, podłącz do VIN dla 15dB. Pin SD: pozostaw niepodłączony lub ustaw HIGH, aby włączyć; ustaw LOW lub podłącz do GND, aby wyłączyć.

Przykładowy schemat połączeń — 3W amplifier MAX98357A I2S DAC

Z Do Przewód
board:5V x1:VIN red
board:GND x1:GND black
board:D9 x1:BCLK green
board:D8 x1:LRC blue
board:D10 x1:DIN yellow

Przykładowy kod Arduino — 3W amplifier MAX98357A I2S DAC

Ten przykład został napisany i sprawdzony kompilacją dla arduino-uno. Codey Online dostosuje go do każdej innej obsługiwanej płytki.

#include <Arduino.h>

// Canonical beginner example for MAX98357A on Arduino Uno.
//
// Important:
// The Arduino Uno (AVR) cannot generate hardware I2S with the standard core,
// so this sketch demonstrates the wiring and control pins, then produces a very
// simple software-generated square-wave audio pattern on the data pin.
//
// Wiring used:
//   D9  -> BCLK
//   D8  -> LRC
//   D10 -> DIN
//   5V  -> VIN
//   GND -> GND

const uint8_t PIN_BCLK = 9;
const uint8_t PIN_LRC  = 8;
const uint8_t PIN_DIN  = 10;

const unsigned int toneHz = 440;
const unsigned long toneOnMs = 1000;
const unsigned long toneOffMs = 500;

void outputSquareWave(unsigned long durationMs, unsigned int frequencyHz) {
  // This does not create real I2S audio; it is only a simple beginner demo.
  // The MAX98357A requires an I2S-capable source for proper audio playback.
  unsigned long start = millis();
  unsigned long halfPeriodUs = 500000UL / frequencyHz;

  while (millis() - start < durationMs) {
    digitalWrite(PIN_DIN, HIGH);
    delayMicroseconds(halfPeriodUs);
    digitalWrite(PIN_DIN, LOW);
    delayMicroseconds(halfPeriodUs);
  }
}

void setup() {
  pinMode(PIN_BCLK, OUTPUT);
  pinMode(PIN_LRC, OUTPUT);
  pinMode(PIN_DIN, OUTPUT);

  digitalWrite(PIN_BCLK, LOW);
  digitalWrite(PIN_LRC, LOW);
  digitalWrite(PIN_DIN, LOW);

  Serial.begin(115200);
  Serial.println(F("MAX98357A example starting."));
  Serial.println(F("Arduino Uno does not support native I2S in the standard AVR core."));
  Serial.println(F("This sketch only demonstrates basic pin control on the labeled connections."));
}

void loop() {
  Serial.println(F("Tone ON"));
  outputSquareWave(toneOnMs, toneHz);

  Serial.println(F("Tone OFF"));
  digitalWrite(PIN_DIN, LOW);
  delay(toneOffMs);
}

Podobne komponenty

Active Buzzer Module

Active Buzzer Module

⚙️

LED

LED Matrix Module MAX7219

LED Matrix Module MAX7219

Passive Buzzer Module

Passive Buzzer Module

Zbuduj swój projekt Arduino lub ESP32 z pomocą AI

Opisz, co chcesz zbudować. Codey Online napisze kod, narysuje schemat połączeń, skompiluje projekt i wgra go na płytkę bezpośrednio z przeglądarki.

Zacznij za darmo