Example 20‐Dependent input - GSTCH/SketchMadeEASY GitHub Wiki
Input that defines the brightness of the LED depends on the position of a switch. If Sketch Made EASY is installed, it can be opened via menu: "File:/Example/SketchMadeEASY/Examples/20-DependentInput".

#include <Easy.h>
//*****************************************************************
// Parameter switch
#define PIN_SWITCH_MODE1 40
#define PIN_SWITCH_MODE2 42
#define INPUT_VALUES_COUNT 3
#define LED_PIN 6
void setup()
{
//((*** Initialize: Configure your sketch here....
// Switch define the input to use
Input* modeSelectorSwitch = new Switch3Position(PIN_SWITCH_MODE1, PIN_SWITCH_MODE2);
// DependentInput use the input in relation of the switch value.
Input* dependentInput = new DependentInput(
modeSelectorSwitch,
FixValue::Off(), // Pos0: Off
FixValue::Percent(50), // Pos1: 50%
new VariableInput(A0)); // Pos2: Variable: 0..100%
// Create actuator
Actuator* led = new VariableOutput(LED_PIN);
// Define logic with a relation (without any condition)
Relation* switchOnRelation = new Relation1to1(NULL, led, dependentInput);
// ***))
// Initialize control
ControlManagerFactory::GetControlManager()->Setup();
}
//*****************************************************************
void loop() {
//*** Run: No additional code is required
ControlManagerFactory::GetControlManager()->Loop();
delay(5);
}