Aller au contenu
Bamba IoT

KY-010 : câblage ESP32, code et brochage

Modules KY-0xxNumérique

Le KY-010 est un module photo-interrupteur qui détecte les objets en détectant les interruptions dans un faisceau infrarouge.

Photo du KY-010

Démarrer

Câblage vers l’ESP32

Câblage vers l’ESP32
Broche du capteurBroche ESP32StatutRôle
Pin (-)GNDRequisSol
Pin (+)3.3V or 5VRequisAlimentation
Pin (S)GPIO15RequisEntrée numérique (n'importe quel GPIO)
Schéma de câblage du KY-010

Code

Aucune bibliothèque à installer.

basic.ino
int sensorPin = 10; // Sensor connected to digital pin 10
int ledPin = 13;    // LED connected to digital pin 13
int sensorValue = 0;

void setup() {
    pinMode(ledPin, OUTPUT);
    pinMode(sensorPin, INPUT);
    digitalWrite(sensorPin, HIGH); // Enable internal pull-up resistor
    Serial.begin(9600);
}

void loop() {
    sensorValue = digitalRead(sensorPin);
    if (sensorValue == HIGH) {
        digitalWrite(ledPin, HIGH); // Turn on LED
        Serial.println("Object detected");
    } else {
        digitalWrite(ledPin, LOW); // Turn off LED
    }
    delay(100);
}

Brochage

Brochage
BrocheTypeDescription
Pin (-)PowerConnexion à la terre
Pin (+)PowerAlimentation3,3 V ou 5 V
Pin (S)CommunicationSortie de signal numériqueChange d'état lorsque le faisceau est interrompu
Brochage du KY-010

Caractéristiques

Le KY-010 est un module photo-interrupteur qui détecte les objets en détectant les interruptions dans un faisceau infrarouge. Il est idéal pour les applications nécessitant une détection d'objets sans contact, telles que le comptage ou la mesure de vitesse.

Caractéristiques
CaractéristiqueValeur
Dimensions19 mm x 15 mm
Slot Width5 mm
Output TypeDigital
Operating Voltage3.3V - 5V