Skip to content

Relay

Latest

Choose a tag to compare

@X-croot X-croot released this 12 Jul 21:01
108d2bd

**# RelayXCR

RelayXCR is a simple and lightweight Arduino library for controlling one or more relay modules using digital pins. It supports both active HIGH and active LOW relays, making it flexible for a wide range of relay boards.

Features

  • Supports multiple relay instances
  • Works with both active HIGH and active LOW logic
  • Simple API: on(), off(), toggle(), isOn()
  • Lightweight and easy to integrate

Installation

  1. Download or clone the repository.
  2. Copy the RelayXCR folder into your Arduino libraries/ directory.
  3. Restart the Arduino IDE.

Usage

Include the Library

#include <RelayXCR.h>

Create Relay Objects

RelayXCR relay1(7);          // Active HIGH (default)
RelayXCR relay2(8, false);   // Active LOW

In setup()

void setup() {
  relay1.begin();
  relay2.begin();
}

In loop()

void loop() {
  relay1.on();
  delay(1000);
  relay1.off();
  delay(1000);
  relay2.toggle();
  delay(1000);
}

API Reference

  • begin() – Initializes the relay pin
  • on() – Turns the relay on
  • off() – Turns the relay off
  • toggle() – Switches the relay state
  • isOn() – Returns true if relay is on, false otherwise

Compatibility

  • Works with any Arduino board
  • Tested with HC-SR501 relay modules, Songle relays, and more

License

MIT License


Created by X-croot
Email: [unuvarcan111@gmail.com](mailto:unuvarcan111@gmail.com)**