Advertisement
pleasedontcode

SD Card & Camera rev_01

May 18th, 2024
849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: SD Card & Camera
  13.     - Source Code NOT compiled for: Arduino Nano ESP32
  14.     - Source Code created on: 2024-05-19 00:04:49
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Présence des Objects */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <SPI.h>
  25. #include <SdFat.h>  // https://github.com/greiman/SdFat
  26. #include <ESP32_OV5640_AF.h>  // https://github.com/0015/ESP32-OV5640-AF
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF SPI PINS *****/
  33. const uint8_t Bb_SDCardModule_SPI_PIN_MOSI_D11 = 11;
  34. const uint8_t Bb_SDCardModule_SPI_PIN_MISO_D12 = 12;
  35. const uint8_t Bb_SDCardModule_SPI_PIN_SCLK_D13 = 13;
  36. const uint8_t Bb_SDCardModule_SPI_PIN_CS_D10 = 10;
  37.  
  38. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  39. SdFs sd; // Create an instance of the SdFs class from the SdFat library
  40. OV5640 ov5640; // Create an instance of the OV5640 class from the ESP32_OV5640_AF library
  41.  
  42. void setup(void)
  43. {
  44.     // Présence des Objects
  45.  
  46.     // put your setup code here, to run once:
  47.  
  48.     pinMode(Bb_SDCardModule_SPI_PIN_CS_D10, OUTPUT);
  49.     // start the SPI library:
  50.     SPI.begin();
  51.  
  52.     // Initialize the SdFat library
  53.     if (!sd.begin(Bb_SDCardModule_SPI_PIN_CS_D10)) {
  54.         Serial.println("SD initialization failed.");
  55.         // Add error handling code here
  56.     }
  57.  
  58.     // Initialize the OV5640 library
  59.     sensor_t* sensor = esp_camera_sensor_get();
  60.     if (ov5640.start(sensor)) {
  61.         Serial.println("OV5640 initialized successfully.");
  62.     } else {
  63.         Serial.println("OV5640 initialization failed.");
  64.     }
  65.  
  66.     if (ov5640.focusInit() == 0) {
  67.         Serial.println("OV5640_Focus_Init Successful!");
  68.     }
  69.  
  70.     if (ov5640.autoFocusMode() == 0) {
  71.         Serial.println("OV5640_Auto_Focus Successful!");
  72.     }
  73. }
  74.  
  75. void loop(void)
  76. {
  77.     // put your main code here, to run repeatedly:
  78.  
  79. }
  80.  
  81. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement