Codey OnlineBiblioteka komponentów Arduino i ESP32 › HW-201 Infrared Obstacle Avoidance Module
HW-201 Infrared Obstacle Avoidance Module
Czujniki

HW-201 Infrared Obstacle Avoidance Module

Moduł czujnika podczerwieni do wykrywania przeszkód HW-201, przełącznik zbliżeniowy do inteligentnego samochodu i Arduino

Szerokość: 38.1 mm

Pinout — HW-201 Infrared Obstacle Avoidance Module

Pin Sygnał Opis
VCC power Positive supply input for the IR obstacle sensor module, typically 3.3–5V.
GND ground Ground reference for power and the OUT signal.
OUT digital Digital comparator output indicating obstacle detection, usually active-low.

Przykładowy schemat połączeń — HW-201 Infrared Obstacle Avoidance Module

Z Do Przewód
board:5V x1:VCC red
board:GND x1:GND black
board:D2 x1:OUT green

Przykładowy kod Arduino — HW-201 Infrared Obstacle Avoidance Module

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

// HW-201 Infrared Obstacle Avoidance Module
// Reads the module's digital OUT pin and prints obstacle status to Serial.
// Many HW-201 modules are active-low: OUT goes LOW when an obstacle is detected.

const int sensorPin = 2;

void setup() {
  pinMode(sensorPin, INPUT);
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("HW-201 Infrared Obstacle Avoidance Module");
  Serial.println("Active-low output: LOW = obstacle detected, HIGH = no obstacle");
}

void loop() {
  int state = digitalRead(sensorPin);

  if (state == LOW) {
    Serial.println("Obstacle detected");
  } else {
    Serial.println("No obstacle");
  }

  delay(200);
}

Podobne komponenty

18650 Battery Shield with USB-C Charger and 5V Boost Converter

18650 Battery Shield with USB-C Charger and 5V Boost Converter

2.4 inch OLED Display I2C 3.3V

2.4 inch OLED Display I2C 3.3V

3.5 inch TFT LCD Shield

3.5 inch TFT LCD Shield

50kg Load Cell Weight Sensor

50kg Load Cell Weight Sensor

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