Esp32 and ov7670

im new to all this and this site. just switched over from arduino to esp32 for this next project due to processing power. im attempting to have a flashlight track movement but starting withy a lazer point for simplicity. using a camera module i already have ov7670 without fifo memory and using my esp32 wrover module to both relay the camera footage back to my computer and move soon to be servos

my current code :

#include "esp_camera.h"
#include <WiFi.h>

#define CAMERA_MODEL_WROVER_KIT

#include "camera_pins.h"

// LASER PIN Definition
#define LASER_PIN 4 

//#define CAMERA_PIN_PWDN -1 
//#define CAMERA_PIN_RESET -1 
#define CAMERA_PIN_XCLK 19
#define CAMERA_PIN_SIOD 21
#define CAMERA_PIN_SIOC 22
// ... More definitions ...
#define CAMERA_PIN_D0 32
#define CAMERA_PIN_D1 33
#define CAMERA_PIN_D2 25
#define CAMERA_PIN_D3 26
#define CAMERA_PIN_D4 27
#define CAMERA_PIN_D5 14
#define CAMERA_PIN_D6 12
#define CAMERA_PIN_D7 13
#define CAMERA_PIN_VSYNC 5
#define CAMERA_PIN_HREF 4
#define CAMERA_PIN_PCLK 18

// WiFi Credentials
const char* ssid = "TELUS0741";
const char* password = "6dvykg6f92";

// Function declarations
void startCameraServer();

void activateLaser(bool activate) {
    digitalWrite(LASER_PIN, activate ? HIGH : LOW);
}







void setup() {
    Serial.begin(115200);
    pinMode(LASER_PIN, OUTPUT);

    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
        Serial.println("Connecting to WiFi...");
    }
    Serial.println("WiFi connected");

    camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = CAMERA_PIN_D0;
  config.pin_d1 = CAMERA_PIN_D1;
  config.pin_d2 = CAMERA_PIN_D2;
  config.pin_d3 = CAMERA_PIN_D3;
  config.pin_d4 = CAMERA_PIN_D4;
  config.pin_d5 = CAMERA_PIN_D5;
  config.pin_d6 = CAMERA_PIN_D6;
  config.pin_d7 = CAMERA_PIN_D7;
  config.pin_xclk = CAMERA_PIN_XCLK;
  config.pin_pclk = CAMERA_PIN_PCLK;
  config.pin_vsync = CAMERA_PIN_VSYNC;
  config.pin_href = CAMERA_PIN_HREF;
  config.pin_sccb_sda = CAMERA_PIN_SIOD;
  config.pin_sccb_scl = CAMERA_PIN_SIOC;
  //config.pin_pwdn = CAMERA_PIN_PWDN;
  //config.pin_reset = CAMERA_PIN_RESET;
  config.xclk_freq_hz = 20000000;
  config.frame_size = FRAMESIZE_UXGA;
  config.pixel_format = PIXFORMAT_JPEG; // for streaming
  //config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition
  config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
  config.fb_location = CAMERA_FB_IN_PSRAM;
  config.jpeg_quality = 12;
  config.fb_count = 1;



    // Camera initialization
    esp_err_t err = esp_camera_init(&config);
    if (err != ESP_OK) {
        Serial.printf("Camera init failed with error 0x%x", err);
        return;
    }
    startCameraServer();
    
    // Additional setup code can go here if needed.
}

void loop() {
    // Loop code can go here. For demonstration purposes, the laser is toggled every 10 seconds.
    static unsigned long lastToggleTime = 0;
    if (millis() - lastToggleTime > 10000) {
        activateLaser(digitalRead(LASER_PIN) == LOW);
        lastToggleTime = millis();
    }
}

Are you using a Nano ESP32 ?

no its not.

I moved your topic to a more appropriate forum category @brettfitzy.

The Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.

In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

1 Like