Codey OnlineBiblioteka komponentów Arduino i ESP32 › Logic Level Shifter 4-channel
Logic Level Shifter 4-channel
Komunikacja

Logic Level Shifter 4-channel

4-kanałowy dwukierunkowy konwerter poziomów logicznych (typ BSS138), który konwertuje między 5V a 3.3V na maksymalnie 4 liniach sygnałowych. مناسبny do I2C (2x), SPI (1x) lub UART (2x). Działa także z modułami/układami 2.8V lub 1.8V.

Protokoły: I2C, SPI, UART Szerokość: 14.9 mm

Pinout — Logic Level Shifter 4-channel

Pin Sygnał Opis
HV1 power top-edge through-hole pin 1 on high-voltage side
HV2 power top-edge through-hole pin 2 on high-voltage side
HV power top-edge through-hole high-voltage supply pin
GND ground top-edge through-hole ground pin
HV3 power top-edge through-hole pin 3 on high-voltage side
HV4 power top-edge through-hole pin 4 on high-voltage side
LV1 power bottom-edge through-hole pin 1 on low-voltage side
LV2 power bottom-edge through-hole pin 2 on low-voltage side
LV power bottom-edge through-hole low-voltage supply pin
GND.1 ground bottom-edge through-hole ground pin
LV3 power bottom-edge through-hole pin 3 on low-voltage side
LV4 power bottom-edge through-hole pin 4 on low-voltage side

Przykładowy schemat połączeń — Logic Level Shifter 4-channel

Z Do Przewód
board:5V x1:HV red
board:GND x1:GND black
board:3.3V x1:LV darkorange
board:GND.1 x1:GND.1 black
board:D2 x1:HV1 green
board:D3 x1:LV1 blue

Przykładowy kod Arduino — Logic Level Shifter 4-channel

Ten przykład został napisany i sprawdzony kompilacją dla arduino-uno. Codey Online dostosuje go do każdej innej obsługiwanej płytki.

// Canonical beginner example for a 4-channel logic level shifter
// Demonstrates shifting a digital signal between the Arduino Uno's 5V side (HV)
// and 3.3V side (LV) using one channel of the module.

const int hvPin = 2; // Connected to HV1
const int lvPin = 3; // Connected to LV1

void setup() {
  pinMode(hvPin, OUTPUT);
  pinMode(lvPin, INPUT);

  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  Serial.println("Logic level shifter example started.");
  Serial.println("Press ENTER in the Serial Monitor to switch the signal.");

  // Start with the signal LOW.
  digitalWrite(hvPin, LOW);
}

void loop() {
  // Drive the 5V side HIGH, then read the translated 3.3V side.
  digitalWrite(hvPin, HIGH);
  delay(10);
  int lvReadingHigh = digitalRead(lvPin);
  Serial.print("HV1 driven HIGH, LV1 reads: ");
  Serial.println(lvReadingHigh);

  delay(1000);

  // Drive the 5V side LOW, then read the translated 3.3V side.
  digitalWrite(hvPin, LOW);
  delay(10);
  int lvReadingLow = digitalRead(lvPin);
  Serial.print("HV1 driven LOW, LV1 reads: ");
  Serial.println(lvReadingLow);

  delay(1000);
}

Podobne komponenty

Logic Level Shifter 8-channel

Logic Level Shifter 8-channel

MAX485 TTL to RS485 Converter Module

MAX485 TTL to RS485 Converter Module

Zbuduj swój projekt Arduino lub ESP32 z pomocą AI

Opisz, co chcesz zbudować. Codey Online napisze kod, narysuje schemat połączeń, skompiluje projekt i wgra go na płytkę bezpośrednio z przeglądarki.

Zacznij za darmo