SKU: OT2043-A54 Numéro d’article: AB072 EAN: 4577243565130
Module d’évitement d’obstacles infrarouge.
Fournit un signal de 5V lorsqu’il n’y a pas d’obstacles et un signal de 0V lorsqu’il y a un obstacle, et la LED verte s’allume. La distance peut être réglée à l’aide d’un potentiomètre. Fonctionne avec 3,3V et 5V, possède une LED d’alimentation rouge.
Mesure la distance aux obstacles à une distance de 2 à 30 cm et sous un angle de 35 degrés au moyen de signaux infrarouges. Contient un émetteur et un récepteur infrarouges.
Dimensions
Longueur : 4,5 cm
Largeur : 1,4 cm
Hauteur : 0,9 cm
Voici comment connecter le Module d’évitement d’obstacles infrarouge HW-201 à un Arduino UNO ou à un ESP32, avec un exemple de sketch que tu peux téléverser directement.
Ce projet utilise un capteur infrarouge d'évitement d'obstacles HW-201 pour détecter les objets proches. Lorsqu'un obstacle entre dans la zone de détection, la sortie numérique du capteur passe à LOW, ce qui allume la LED intégrée de l'Arduino et affiche des alertes de détection dans le Serial Monitor. Réglez le potentiomètre intégré du module capteur pour calibrer la distance de détection.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : IR Obstacle Detection with HW-201
* Board : Arduino UNO (arduino:avr:uno)
* Parts : HW-201 Infrared Obstacle Avoidance Module
* Libraries : none (built-in)
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
// Pin definitions
const int sensorPin = 2;
const int ledPin = 13;
void setup() {
pinMode(sensorPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
Serial.println(F("HW-201 IR Obstacle Sensor Demo"));
Serial.println(F("Ready: Move an object in front of the sensor."));
}
void loop() {
// The HW-201 sensor outputs LOW when an obstacle is detected
int sensorState = digitalRead(sensorPin);
if (sensorState == LOW) {
digitalWrite(ledPin, HIGH);
Serial.println(F("Obstacle Detected!"));
} else {
digitalWrite(ledPin, LOW);
Serial.println(F("Clear (no obstacle)"));
}
delay(200);
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online
Ce projet lit la sortie numérique du HW-201 Infrared Obstacle Avoidance Module. Lorsqu’un objet est détecté à portée, la sortie du capteur passe à LOW, ce qui allume la LED intégrée de l’ESP32 et affiche une alerte dans le Serial Monitor. Vous pouvez régler la distance de détection à l’aide du potentiomètre sur le module.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : IR Obstacle Detection with ESP32
* Board : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
* Parts : HW-201 Infrared Obstacle Avoidance Module
* Libraries : none (built-in)
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
// HW-201 IR Obstacle Sensor with ESP32
const int SENSOR_PIN = 4; // Connected to OUT pin of HW-201
const int LED_PIN = 2; // Onboard LED
void setup() {
Serial.begin(115200);
pinMode(SENSOR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.println("HW-201 Obstacle Sensor Ready");
}
void loop() {
// The HW-201 output is active-LOW (LOW when an obstacle is detected)
int sensorState = digitalRead(SENSOR_PIN);
if (sensorState == LOW) {
digitalWrite(LED_PIN, HIGH);
Serial.println("Obstacle detected!");
} else {
digitalWrite(LED_PIN, LOW);
Serial.println("Path clear");
}
delay(200);
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online