Before creating the library, one must understand the hardware.
| Feature | Library A (The Engineering Projects) | Library B (GitHub - Asim Zia) | Library C (DIY Macro) | | :--- | :--- | :--- | :--- | | Visual PCB View | Yes (3D-like) | No (Schematic only) | Optional | | LED Indicators | Yes (Red LEDs) | Yes (Text label) | Yes (User-defined) | | Input Logic | Active Low | Active High (Configurable) | Configurable | | Optocoupler Model | No (Direct transistor) | Yes (PC817 inside) | No (User must add) | | Ease of Installation | Easy (Copy-Paste) | Moderate (needs index rebuild) | Complex (Requires assembly) | | Best For | Beginners / Hobbyists | Industrial simulation | Advanced users |
Our Verdict: For 90% of users, Library A (The Engineering Projects) is the most stable and visually informative. For high-voltage isolation studies, choose Library B.
If you need to create this library from scratch, follow these steps:
| Pin Name | Description | | :--- | :--- | | VCC | Module power supply (5V/12V) | | GND | Ground | | IN1 | Control signal for Relay 1 (Active Low/High) | | IN2 | Control signal for Relay 2 | | IN3 | Control signal for Relay 3 | | IN4 | Control signal for Relay 4 | | COM (x4) | Common terminal for each relay | | NO (x4) | Normally Open terminal | | NC (x4) | Normally Closed terminal |
In simulation, we often ignore the heavy AC load but must accurately model the switching behavior and the inverted logic.
void setup() pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT);
void loop() digitalWrite(2, HIGH); // Relay1 ON delay(1000); digitalWrite(2, LOW); // Relay1 OFF digitalWrite(3, HIGH); // Relay2 ON delay(1000); digitalWrite(3, LOW); // ... similarly for channels 3 and 4











