Example 04 ‐ Blinking LED - GSTCH/SketchMadeEASY GitHub Wiki

This document describe a toggling LED (the most common hello world example with Arduino). If Sketch Made EASY is installed, it can be opened via menu: "File:/Example/SketchMadeEASY/Example/04-BlinkingLed".

Schematic

Code

#include <Easy.h>

//*****************************************************************
#define TIMER_INTERVAL_MSEC 1500
#define LED_PIN 6

void setup() {
  //((*** Initialize: Configure your sketch here....

  //** Create input:
  // Input changes value periodically and toggles between High and Low.
  Input* timer = new Timer(TIMER_INTERVAL_MSEC, true);

  //** Create actuator. 
  // A DigitalOutput knows the value On and Off.
  Actuator* led = new DigitalOutput(LED_PIN);

  //** Define logic with conditions and relations
  // Define relation when timer value changes to High
  Condition* conditionLedOn = new CompareCondition(timer, OpEQ, Timer::High);
  Relation* relationLedOn = new Relation1to1(conditionLedOn, led, FixValue::On());

  // Define relation when timer value changes to Low
  Condition* conditionLedOff = new CompareCondition(timer, OpEQ, Timer::Low);
  Relation* relationLedOff = new Relation1to1(conditionLedOff, led, FixValue::Off());
  // ***))

  // Initialize control
  ControlManagerFactory::GetControlManager()->Setup();
}

//*****************************************************************
void loop() {
  //*** Run: No additional code is required
  ControlManagerFactory::GetControlManager()->Loop();

  // Depending on Arduino it needs a short delay. Do not add any other delays!
  delay(5);
}
⚠️ **GitHub.com Fallback** ⚠️