Démarrer
Câblage vers l’ESP32
| Broche du capteur | Broche ESP32 | Statut | Rôle |
|---|---|---|---|
| Pin (-) | GND | Requis | Sol |
| Pin (middle) | 3.3V or 5V | Requis | Alimentation |
| Pin (S) | GPIO36 | Requis | Entrée analogique (broche ADC) |

Code
Aucune bibliothèque à installer.
int sensorPin = A0; // Photoresistor connected to analog pin A0
int sensorValue = 0;
void setup() {
Serial.begin(9600);
Serial.println("KY-018 Photoresistor Test");
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.print("Light Intensity: ");
Serial.println(sensorValue);
delay(500);
}
Brochage
Caractéristiques
Le KY-018 est un module photorésistant qui détecte les niveaux de lumière ambiante. Il émet un signal analogique correspondant à l'intensité lumineuse, ce qui le rend adapté aux projets nécessitant des capacités de détection de la lumière.
| Caractéristique | Valeur |
|---|---|
| Dimensions | 21 x 15 x 6 mm |
| Output Type | Analog |
| Operating Voltage | 3.3V - 5V |
| Fixed Resistor Value | 10 kΩ |

