// https://wokwi.com/projects/359457444067954689
// https://forum.arduino.cc/t/hacking-automatic-resin-filler-for-anycubic-m3-for-other-models/1097122

// TinyDebug mini-manual:
//    # include "TinyDebug.h" - Debug.begin(); - Debug.println(F("Hello Tiny!"));

# include <TinyDebug.h>

# define fullvatswitch_pin 1
# define bottlecapapcityswitch_pin 2
# define ps_pin 4

void setup()
{
  Debug.begin();

//define pins
  pinMode(fullvatswitch_pin, INPUT);
  pinMode(bottlecapapcityswitch_pin, INPUT);
  pinMode(ps_pin, OUTPUT);
  digitalWrite(ps_pin, LOW);
}

void loop()
{
  byte bottleCapacity = digitalRead(bottlecapapcityswitch_pin);
  byte vatFull = digitalRead(fullvatswitch_pin);

  delay(250); // just until

  if (!bottleCapacity) {
    digitalWrite(ps_pin, LOW);
    Debug.println(F("resin bottle empty"));
  }

  if (bottleCapacity && !vatFull) {
    Debug.println(F("one minute pump delay 5 seconds"));
    delay(5000);//1 minute pump delay

    digitalWrite(ps_pin, HIGH);
    Debug.println(F("soleniods and pump on"));
  }

  if (bottleCapacity && vatFull) {
    Debug.println(F("delay pump off 3 seconds"));
    delay(3000);
    digitalWrite(ps_pin, LOW);
  }
}
ATTINY8520PU
VAT FULL
BOTL CAP
PS_PIN