User Tools

Site Tools


esp32-cam-ch340_capture_photo

This is an old revision of the document!


Capture photo w/ ESP32-CAM-CH340

https://randomnerdtutorials.com/esp32-cam-take-photo-display-web-server/

On récapitule:

Pour ajouter un flash

Ajouter les lignes suivantes: ligne 34:

boolean flashlight = false;

ligne 57:

#define LED_BUILTIN 4

ligne 76:

<button onclick="captureWithFlashlight()">CAPTURE WITH FLASHLIGHT</button>

ligne 89:

function captureWithFlashlight() {
  var xhr = new XMLHttpRequest();
  xhr.open('GET', "/capturewithflashlight", true);
  xhr.send();
}

ligne 108:

pinMode (LED_BUILTIN, OUTPUT);

ligne 182:

server.on("/capturewithflashlight", HTTP_GET, [](http://AsyncWebServerRequest * request) {
  takeNewPhoto = true;
  flashlight = true;
  request->send(200, "text/plain", "Taking Photo");
});

function loop devient:

if (takeNewPhoto) {
  if (flashlight) digitalWrite(LED_BUILTIN, HIGH);
  capturePhotoSaveSpiffs();
  takeNewPhoto = false;
  if (flashlight) {
    digitalWrite(LED_BUILTIN, LOW);
    flashlight = false;
  }
}
esp32-cam-ch340_capture_photo.1742393307.txt.gz · Last modified: 2025/03/19 14:08 by bruno