

The 6N138 is an optocoupler (also known as an opto-isolator) that provides electrical isolation between its input and output. It consists of a light-emitting diode (LED) and a photodetector, allowing signals to be transmitted while preventing direct electrical connection. This component is commonly used in applications requiring signal isolation, such as interfacing between different voltage levels or protecting sensitive components from high voltages.








The 6N138 is an 8-pin DIP (Dual Inline Package) component. Below is the pinout and description:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | Anode (LED) | Positive terminal of the input LED. Connect to the input signal. |
| 2 | Cathode (LED) | Negative terminal of the input LED. Connect to ground or a current-limiting resistor. |
| 3 | NC (No Connect) | Not connected internally. Leave unconnected or use as a mechanical support. |
| 4 | Emitter (Output) | Emitter terminal of the phototransistor. Typically connected to ground. |
| 5 | Collector (Output) | Collector terminal of the phototransistor. Connect to the output circuit. |
| 6 | Base (Optional) | Base terminal of the phototransistor. Can be left unconnected or used for biasing. |
| 7 | Vcc | Positive supply voltage for the output side. |
| 8 | GND | Ground connection for the output side. |
Input Side (LED):
R = (Vin - Vf) / IfR = (5V - 1.2V) / 0.01A = 380Ω (use the nearest standard resistor value, e.g., 390Ω).Output Side (Phototransistor):
Power Supply:
The following example demonstrates how to use the 6N138 to isolate a digital input signal for an Arduino UNO:
// Example code for using the 6N138 optocoupler with Arduino UNO
const int inputPin = 2; // Digital pin connected to the 6N138 output
void setup() {
pinMode(inputPin, INPUT); // Set the input pin as an input
Serial.begin(9600); // Initialize serial communication at 9600 baud
}
void loop() {
int signalState = digitalRead(inputPin); // Read the signal from the optocoupler
if (signalState == HIGH) {
Serial.println("Signal HIGH"); // Print message if signal is HIGH
} else {
Serial.println("Signal LOW"); // Print message if signal is LOW
}
delay(500); // Wait for 500ms before reading again
}
No Output Signal:
Output Signal is Always HIGH or LOW:
Slow Response Time:
Component Overheating:
Q: Can the 6N138 be used for analog signal isolation?
A: The 6N138 is primarily designed for digital signal isolation. While it can transmit analog signals, the linearity and bandwidth may be limited.
Q: What is the purpose of the base pin (Pin 6)?
A: The base pin can be used for biasing the phototransistor to adjust its sensitivity or response time. In most cases, it can be left unconnected.
Q: How do I calculate the pull-up resistor value?
A: The pull-up resistor value depends on the desired output current and speed. A typical value is 10kΩ, but for faster response times, a lower value (e.g., 4.7kΩ) may be used.