Skip to content

X-croot/RelayXCR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files 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. resim

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

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

Packages

 
 
 

Contributors

Languages