SSR for heater PWM control

SSR for heater PWM control

animation
actuators
// SSR for heater PWM control
#define SSR_PIN 27

void setup() {
  // SSR can handle PWM for proportional heating
  ledcSetup(0, 1, 8);  // 1 Hz (1 cycle/second), 8-bit resolution (0-255)
  ledcAttachPin(SSR_PIN, 0);
}

void setHeaterPower(int percent) {
  // 0-100% maps to 0-255
  int duty = map(percent, 0, 100, 0, 255);
  ledcWrite(0, duty);
}

Back to the chapter