Example Code for Arduino-Signal Level Conversion
This project demonstrates how to use the 2-Channel Level Converter with DFRduino UNO R3 to convert 12V industrial sensor signals to 5V for Arduino compatibility. Users can learn how to connect the level converter to Arduino and read the converted signal via the serial monitor.
Hardware Preparation
- DFRduino UNO R3 ×1
- 2-Channel Level Converter ×1
- Wires
Software Preparation
Wiring Diagram
Connection of Single-channel common anode 3-wire sensor to the UNO board.

Sample Code
int input_pin = 7;
void setup()
{
Serial.begin(9600);
pinMode(input_pin, INPUT);
// pinMode(inpin, INPUT_PULLUP);//Input mode internal pull-up
}
void loop()
{
int reading = digitalRead (input_pin);
Serial.println(reading);
delay(100);
}
Result
If the signal input is low level 0, open the UNO serial port, then you can see it stably outputs high level 1.
Additional Information

NOTE:
- When other different voltages and levels are converted, the resistance values in the diagram are different.
- The module has a low output current and cannot drive modules such as relays or solenoid valves.
Was this article helpful?
