Repository navigation
**# 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
- Download or clone the repository.
- Copy the
RelayXCRfolder into your Arduinolibraries/directory. - 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 LOWIn 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 pinon()– Turns the relay onoff()– Turns the relay offtoggle()– Switches the relay stateisOn()– Returnstrueif relay is on,falseotherwise
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)**