github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/examples/i2s/i2s.go (about)

     1  // Example using the i2s hardware interface on the Adafruit Circuit Playground Express
     2  // to read data from the onboard MEMS microphone.
     3  package main
     4  
     5  import (
     6  	"machine"
     7  )
     8  
     9  func main() {
    10  	machine.I2S0.Configure(machine.I2SConfig{
    11  		Mode:        machine.I2SModePDM,
    12  		ClockSource: machine.I2SClockSourceExternal,
    13  		Stereo:      true,
    14  	})
    15  
    16  	data := make([]uint32, 64)
    17  
    18  	for {
    19  		// get the next group of samples
    20  		machine.I2S0.Read(data)
    21  
    22  		println("data", data[0], data[1], data[2], data[4], "...")
    23  	}
    24  }