/***************************************************************************************
* Description: Turn on relays and indicatior LEDs
* Sketch: relay_control.ino
* Version: 1.0
* Version Desc: First version
* Board: ESP32 C3
* Author: Steve Fuller
* Website:
* Comments sketch uses local libraries and namespaces to make code cleaner
* the PB turns on the Power Relay AND Feedback relay. The contacts from
* the feedback relay turns on the feedback LED
*
* Version 2.0 uses the NO contact of the Power Relay to turn on the
* Feedback Relay which indicates via the Feedback LED that the relay
* command has functioned
***************************************************************************************/
#include "globals.h" // global definitions
#include "ledHelper.h" // local library for LED control
#include "hardwareHelper.h" // local library for relays and PB's
#include <stdio.h>
void setup() {
hardware::Setup(); // set up the relays and pushbuttons
led::Setup(); // set up the LEDs
printf("Remote relay and feedback\n");
printf("-------------------------\n");
printf("Pressing the PB will energise the Power relay and light the green LED\n");
printf("\n");
printf("When the NO contact closes, it energises the Feedback relay which\n");
}
void loop() {
delay(10); // this speeds up the simulation
if (PUSHBUTTON_PRESSED){ // if push button is pressed
// turn on relays and power LED
//led::PowerLEDturnOn();
LED_POWER_TURN_ON;
relays::PowerRelayturnOn();
} else { // if push button is not pressed
// turn off relays on power LED
led::PowerLEDturnOff();
relays::PowerRelayturnOff();
}
// check FB relay N.O. contact has closed
// and TURN on feedback LED
if (RELAY_CLOSED){ // if NO contact closed
led::FeedbackLEDturnOn();
} else {
led::FeedbackLEDturnOff();
}
}