#include <Stepper.h>
#include <pitches.h>
#include <FastLED.h>


//----- Buzzer Setup -----
#define SPEAKER_PIN 0
//----- Buzzer END -----

//----- Encoder BTN Setup -----
#define ENCODER_CLK 2
#define ENCODER_DT 3
#define ENCODER_SW 4
int lastClk = HIGH;
//----- Encoder BTN END -----


//----- LEDs Setup -----
#define NUM_LEDS 4
#define DATA_PIN 1
CRGB leds[NUM_LEDS];
//----- LEDs END -----


//----- Stepper Setup -----
const int stepsPerRevolution = 200*64;  // change this to fit the number of steps per revolution for your motor
// initialize the stepper library on pins 8 through 11:
Stepper redStepper(stepsPerRevolution, 5, 6, 7, 8);
Stepper greenStepper(stepsPerRevolution, 9, 10, 20, 21);
//----- Stepper END -----

//----- PCF8575 Setup -----

//----- PCF8575 END -----

void setup() {
  FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
  redStepper.setSpeed(60);
  greenStepper.setSpeed(60);
  PlayRedAlarm();
  pinMode(ENCODER_CLK, INPUT);
  pinMode(ENCODER_DT, INPUT);
  pinMode(ENCODER_SW, INPUT);
  attachInterrupt(digitalPinToInterrupt(ENCODER_SW), Ext_INT1_ISR, RISING);
  attachInterrupt(digitalPinToInterrupt(ENCODER_CLK), readEncoder, FALLING);
}

//void IRAM_ATTR Ext_INT1_ISR()
void Ext_INT1_ISR()
{
  //tone(SPEAKER_PIN, 1900, 250);
  PlayRedAlarm();     
}

void readEncoder() {
  int dtValue = digitalRead(ENCODER_DT);
  if (dtValue == HIGH) {
    tone(SPEAKER_PIN, 300, 250);
    //PlayRedAlarm();
  }
  if (dtValue == LOW) {
    tone(SPEAKER_PIN, 900, 250);
  }
}

void loop() {
  delay(10);
/*
  for (int thisLED = 0; thisLED < NUM_LEDS; thisLED++) {
    leds[thisLED] = CRGB(255, 0, 0);
  }
  FastLED.show();

  while (digitalRead(0) == LOW) {
    //Set stepper to 0 position
    redStepper.step(1);
  }
  for (int thisLED = 0; thisLED < NUM_LEDS; thisLED++) {
    leds[thisLED] = CRGB(0, 0, 0);
  }
  FastLED.show();
  delay(500);
  
    
 
  for (int thisLED = 0; thisLED < NUM_LEDS; thisLED++) {
    leds[thisLED] = CRGB(0, 255, 0);
  }
  FastLED.show();
  
  while (digitalRead(0) == LOW) {
    //Set stepper to 0 position
    greenStepper.step(1);
  }
  for (int thisLED = 0; thisLED < NUM_LEDS; thisLED++) {
    leds[thisLED] = CRGB(0, 0, 0);
  }
  FastLED.show();
  delay(500);
*/
}

Loading
aitewinrobot-esp32c3-supermini
pcf8575Breakout