Really basic question, how can i use a pot to control the seed example sketches?

Total noob

I want to control the seed example file using a potentiometer. I have one on pin A0, the only example that seems to use a pot is the oscillator one but I can’t figure out how to use a pot to control a filter instead of the LFO in the example sketches.

I tried copying that portion of the oscillator sketch to the Moog filter sketch.

why doesn’t it work? (all the lfo stuff is still there) I get no sound.

// Title: moogladder
// Description: Sweeps the cutoff with an lfo
// Hardware: Daisy Seed
// Author: Ben Sergentanis

#include "DaisyDuino.h"

DaisyHardware hw;

size_t num_channels;

static MoogLadder flt;
static Oscillator osc, lfo;

float freq1;

void MyCallback(float **in, float **out, size_t size) {
  float saw, output;
  for (size_t i = 0; i < size; i++) {
    
    saw = osc.Process();

    flt.SetFreq(mtof(freq1));
    output = flt.Process(saw);

    for (size_t chn = 0; chn < num_channels; chn++) {
      out[chn][i] = output;
    }
  }
}

void setup() {
  float sample_rate;
  // Initialize for Daisy pod at 48kHz
  hw = DAISY.init(DAISY_SEED, AUDIO_SR_48K);
  num_channels = hw.num_channels;
  sample_rate = DAISY.get_samplerate();

  // initialize Moogladder object
  flt.Init(sample_rate);
  flt.SetRes(0.7);

  // set parameters for sine oscillator object
  lfo.Init(sample_rate);
  lfo.SetWaveform(Oscillator::WAVE_TRI);
  lfo.SetAmp(1);
  lfo.SetFreq(.4);

  // set parameters for sine oscillator object
  osc.Init(sample_rate);
  osc.SetWaveform(Oscillator::WAVE_POLYBLEP_SAW);
  osc.SetFreq(100);
  osc.SetAmp(0.25);

  DAISY.begin(MyCallback);
}

void loop() {freq1 = 24.0 + ((analogRead(A0) / 1023.0) * 60.0); ;
}

I’ve also seen this type of “map” in other ppls sketches:

void loop() { 

 pitch = map(analogRead(A0), 1, 1020, 24.0, 100.0);

Thanks

Hey @elldawg!

Your code is working on my end actually! I flashed it to my Daisy Pod (it has a potentiometer connected to ADC 0).
What does your circuit look like? Are you using Daisy Seed on a breadboard?

Hi @Takumi_Ogata ,

It is working as written above. I just re-flashed that exact code and it functions correctly! The first time I was using a breadboard, I had been testing things all day and maybe I had something wired incorrectly

This time on a seed in a stripboard with a pot soldered at A0 hooked up to a PAM83023amp and a speaker. Sounds good!

I moved on to working in ~gen for this project as I was getting frustrated in the c++ and Arduino IDE just getting simple things to work, but thanks for checking this!

I think I might try to recreate what I did in ~gen (interpolating between multiple filters/ filter types while simultaneously adjusting multiple parameters with a single knob)

1 Like