CCCPaste

SD Card & Camera rev_01

/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: SD Card & Camera
	- Source Code NOT compiled for: Arduino Nano ESP32
	- Source Code created on: 2024-05-19 00:04:49

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Présence des Objects */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include   // https://github.com/greiman/SdFat
#include   // https://github.com/0015/ESP32-OV5640-AF

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF SPI PINS *****/
const uint8_t Bb_SDCardModule_SPI_PIN_MOSI_D11 = 11;
const uint8_t Bb_SDCardModule_SPI_PIN_MISO_D12 = 12;
const uint8_t Bb_SDCardModule_SPI_PIN_SCLK_D13 = 13;
const uint8_t Bb_SDCardModule_SPI_PIN_CS_D10 = 10;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
SdFs sd; // Create an instance of the SdFs class from the SdFat library
OV5640 ov5640; // Create an instance of the OV5640 class from the ESP32_OV5640_AF library

void setup(void)
{
    // Présence des Objects

    // put your setup code here, to run once:

    pinMode(Bb_SDCardModule_SPI_PIN_CS_D10, OUTPUT);
    // start the SPI library:
    SPI.begin();

    // Initialize the SdFat library
    if (!sd.begin(Bb_SDCardModule_SPI_PIN_CS_D10)) {
        Serial.println("SD initialization failed.");
        // Add error handling code here
    }

    // Initialize the OV5640 library
    sensor_t* sensor = esp_camera_sensor_get();
    if (ov5640.start(sensor)) {
        Serial.println("OV5640 initialized successfully.");
    } else {
        Serial.println("OV5640 initialization failed.");
    }

    if (ov5640.focusInit() == 0) {
        Serial.println("OV5640_Focus_Init Successful!");
    }

    if (ov5640.autoFocusMode() == 0) {
        Serial.println("OV5640_Auto_Focus Successful!");
    }
}

void loop(void)
{
    // put your main code here, to run repeatedly:

}

/* END CODE */