Leslie switch scenario

Try this:

Var
   BRAKE : Widget
   SPEED : Widget
   TimerStarted : Boolean
   StartTime : double
   Delay : double

initialization
 TimerStarted = false
 Delay = 500
 SetTimersRunning(true)
end 
   
on Activate
 TimerStarted = false
 SetTimersRunning(true)
end 

On WidgetValueChanged(newValue : double) from SPEED

 if ParamToMidi(newValue) >= 51
    and ParamToMidi(newValue) <= 79 then
  if TimerStarted == false then
    SetTimersRunning(true)
    TimerStarted = true
    StartTime = TimeSinceStartup()
  end  
 
 else
  BRAKE.SetWidgetValue(0.0)
  SetTimersRunning(false)
  TimerStarted = false
 end 
    
End

on TimerTick(ms : double)
 if TimeSinceStartup() >= StartTime + Delay then
  BRAKE.SetWidgetValue(1.0)
 end 
end
2 Likes