A Feather M4 Express board was enlisted to aid the demonstration of the sensor plotter in the video on the previous page. It provided:
- alternating red, green blue light from the onboard NeoPixel for the CLUE's APDS-9960 colour sensor;
- two analogue signals from A0 and A1 which were connected to the #0 and #1 pads on the CLUE using some test hooks.
Its SAMD51 (M4) processor is useful here as it has 2 DACs.
The code running on the board was very short and simply typed in over the serial console on CircuitPython's REPL.
import audioio, audiocore, board, neopixel, time dacpair = audioio.AudioOut(board.A0, right_channel=board.A1) filename = "adafruit-spinning-logo-plot-2chan.wav" wav_file = open(filename, "rb") samples = audiocore.WaveFile(wav_file) samples.sample_rate = 500 dacpair.play(samples, loop=True) pixel = neopixel.NeoPixel(board.NEOPIXEL, 1) # Loop forever showing r, g, b while the # DACs continue to loop the samples from wav file while True: pixel[0] = (255, 0, 0) # red time.sleep(0.5) pixel[0] = (0, 255, 0) # green time.sleep(0.5) pixel[0] = (0, 0, 255) # blue time.sleep(0.5)
Wav files are typically used for audio but they can be used for any signal. In this case the adafruit-spinning-logo-plot-2chan.wav
has two signals following the top and bottom outline of the Adafruit logo, spinning 1/5th of a revolution in total across five frames.