Analog Disc Echo & Sampler

Hello friendly people of the Arduino forum,

my name is André and I am quite new to Arduino. I am not a complete beginner of the required hard- and software skills – but i found myself wanting stuff without knowing all the correct steps to go there.
I managed to do the basic tutorials and everything worked fine, now i need your help for building up a very unique project of mine. I am very glad if you people find it interesting and (in best case) can help me with it.

Currently I try to figure out how to build a eurorack based module, which on the one hand works as a simple analog tape delay and on the other hand as an analog (yes analog) audio sampler (in stereo).
At the end it should work with DAW–MIDI changes, like start, stop, record, loop, at a synced bpm-rate.

It is a disk-echo built, not a tape or cassette build (Like Binson Echorec or Schaller Amps)
because i want to have exact angle positions of the disk so it runs perfectly in sync and rhythm.

This is achieved by using an Arduino UNO, a 28BYJ-48 stepper motor (already powered by eurorack), a ULN2003 driver (until i get a motor shield), a MIDI shield and an audio shield (right now i use an old walkman-pcb for playback and record).

Right now I managed it to work so far

I attached everything correctly and set up a piece of code.
I built a prototype-echo-disc with a piece of regular cassette tape outside.
I use a simple eurorack mixing module to play with echo-feedback.
I got two buttons (start and stop) on my breadboard,
and a potentiometer to regulate the speed of the echo.

The motor should simply run after the start signal went in (right now by button, later by MIDI),
and it should stop when the stop signal is run in (easy right?).

I set up two interrupt voids (start & stop) but I don't know how to do it correctly – can you help me?
Right now I think its a good way to define states like:

  • PLAY (ACTIVATE PLAYBACK HEAD + TURN MOTOR + LED GREEN ON)

  • PAUSE (MUTE PLAYBACK HEAD + STOP MOTOR)

  • PAUSE LOOP (MUTE LISTEN HEAD + STOP MOTOR + GO BACK TO SET PLAY POSITION (for example beat 1 of 4))

  • RECORD (TURN MOTOR + ACTIVATE RECORD HEAD + LED RED ON + DEACTIVATE RECORD HEAD AFTER 1 DISK-CYCLE + LED RED OFF)

Later I want to change the triggers of these events from hardware to software ones, with certain hierarchy (a put-in audio jack might switch modes, but thats future wishing)

So right now I only need some advise how to set up these states for the motor.

Thank you!

André

#include <Stepper.h> // Hinzufügen der Programmbibliothek.

const int stepsPerRevolution = 512;
Stepper stepper(stepsPerRevolution, 8,10,9,11); // Der Schrittmotor erhält die Bezeichnung "Motor" und es wird angegeben an welchen Pins der Motor angeschlossen ist.
int stepCount = 0;

// Start Button
int buttonstart=2;
int LEDgruen=6;
int statusbuttonstart=0; //Das Wort „statusbuttonstart“ steht jetzt zunächst für den Wert 0. Später wird unter dieser Variable gespeichert, ob der Taster gedrückt ist oder nicht.

// Stop Button
int buttonstop=3;
int LEDrot=7;
int statusbuttonstop=0; //Das Wort „statusbuttonstop“ steht jetzt zunächst für den Wert 0. Später wird unter dieser Variable gespeichert, ob der Taster gedrückt ist oder nicht.

volatile byte statered = LOW;
volatile byte stategreen = LOW;





void setup()
{
Serial.begin(9600);
pinMode(LEDgruen, OUTPUT);
pinMode(LEDrot, OUTPUT);
pinMode(buttonstart, INPUT);
pinMode(buttonstop, INPUT);

stepper.setSpeed(60); // Umdrehungen pro Minute.
attachInterrupt(digitalPinToInterrupt(3), LEDredON, RISING);
attachInterrupt(digitalPinToInterrupt(2), LEDgreenON, RISING);
}





void loop()
{
  //read the sensor value:
  int sensorReading = analogRead(A0);
  
  digitalWrite(LEDrot, statered);
  digitalWrite(LEDgruen, stategreen);
  
  //map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  Serial.println(motorSpeed,DEC);
  
  if (motorSpeed > 0) {
    stepper.setSpeed(motorSpeed);
    //step 1/100 of a revolution:
    stepper.step(stepsPerRevolution / 100);
    }

  if (LEDrot == CHANGE)
  {
    delay (50);
  }

  if (LEDgruen == CHANGE)
  {
    delay (50);
  }

}


void LEDredON ()
  {
   statered = !statered;
  }

void LEDgreenON ()
  {
    stategreen = !stategreen;
  }

LEDrot and LEDgruen are pin numbers. They will never equal the enum value CHANGE (which is a 1).

  if (LEDrot == CHANGE)
  {
    delay (50);
  }

  if (LEDgruen == CHANGE)
  {
    delay (50);
  }

You really don't need interrupts to detect the button changes. You can just monitor for LOW, HIGH, or transitions in the code. Look at this example:

StateChangeDetection

Also, how are your buttons wired? Since you have them declared as INPUT rather INPUT_PULLUP then you need pull-up or pull-down resistors depending on how you have them wired.