Example Code for Arduino - DI1-DI8 Industrial Digital Input Interfaces (Fully Isolated)

Last revision 2026/02/05

Function Description

The DMX512 controller is equipped with 8 channels of fully isolated digital input ports, supporting PNP sensor connection. The voltage level supports 12V-24V. As shown below:
Function Description

Port numbering ESP32-S3 pins Port description
DGND Digital input ground
DI1 IO6 Digital input port 1
DI2 IO7 Digital input port 2
DI3 IO8 Digital input port 3
DI4 IO35 Digital input port 4
DI5 IO36 Digital input port 5
DI6 IO37 Digital input port 6
DI7 IO38 Digital input port 7
DI8 IO39 Digital input port 8

Example: Infrared switch controls the on/off of the light strip

Below, we will connect a PNP infrared switch sensor to pin D1. When the infrared switch detects an obstruction, the LED strip will light up; otherwise, it will turn off.

Wiring diagram

Wiring diagram-1

Programming

If you haven't downloaded and imported the DMX512 library yet, please download it from the following link and import it: https://github.com/DFRobot/DFRobot_DMX512
This program demonstrates using an infrared switch to control the on/off of DMX512 lighting. When the infrared switch is blocked, the light is on; otherwise, it is off.

#include "DFRobot_DMX512.h"

DFRobot_DMX512 dmx512; 

void setup() {
    Serial.begin(115200);  
    while(dmx512.begin() != 0){   //Initialize DMX512
        Serial.println("init error");
        delay(1000);
    }
    Serial.println("init OK");

}

void loop() {
    
    if (dmx512.digitalIN(DI1) == HIGH) {  //The infrared switch is connected to the DI1 interface.
        dmx512.RGBLight(1,8,0,0,0);   //Turn off the first to eighth LED strips.  
    } else {
        dmx512.RGBLight(1,8,0,0,255); //Light up the first to eighth LED strips, displaying them in blue.
    }
}

Was this article helpful?

ON THIS PAGE

TOP