Advertisement
pleasedontcode

ESP32 Control rev_02

May 18th, 2024
739
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: ESP32 Control
  13.     - Source Code NOT compiled for: Arduino Nano ESP32
  14.     - Source Code created on: 2024-05-19 00:07:45
  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 updateOutputs(void); // Added function prototype for updateOutputs
  30.  
  31. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  32. const uint8_t myLCD1602_LCD1602_D4_PIN_D4 = 4;
  33. const uint8_t myLCD1602_LCD1602_D5_PIN_D5 = 5;
  34. const uint8_t myLCD1602_LCD1602_D6_PIN_D6 = 6;
  35. const uint8_t myLCD1602_LCD1602_D7_PIN_D7 = 7;
  36.  
  37. /***** DEFINITION OF SPI PINS *****/
  38. const uint8_t Bb_SDCardModule_SPI_PIN_MOSI_D11 = 11;
  39. const uint8_t Bb_SDCardModule_SPI_PIN_MISO_D12 = 12;
  40. const uint8_t Bb_SDCardModule_SPI_PIN_SCLK_D13 = 13;
  41. const uint8_t Bb_SDCardModule_SPI_PIN_CS_D10 = 10;
  42.  
  43. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  44. bool myLCD1602_LCD1602_D4_PIN_D4_rawData = 0;
  45. bool myLCD1602_LCD1602_D5_PIN_D5_rawData = 0;
  46. bool myLCD1602_LCD1602_D6_PIN_D6_rawData = 0;
  47. bool myLCD1602_LCD1602_D7_PIN_D7_rawData = 0;
  48.  
  49. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  50. float myLCD1602_LCD1602_D4_PIN_D4_phyData = 0.0;
  51. float myLCD1602_LCD1602_D5_PIN_D5_phyData = 0.0;
  52. float myLCD1602_LCD1602_D6_PIN_D6_phyData = 0.0;
  53. float myLCD1602_LCD1602_D7_PIN_D7_phyData = 0.0;
  54.  
  55. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  56. SdFs sd; // Instance of SdFs class from SdFat library
  57. OV5640 ov5640; // Instance of OV5640 class from ESP32_OV5640_AF library
  58.  
  59. void setup()
  60. {
  61.     pinMode(myLCD1602_LCD1602_D4_PIN_D4, OUTPUT);
  62.     pinMode(myLCD1602_LCD1602_D5_PIN_D5, OUTPUT);
  63.     pinMode(myLCD1602_LCD1602_D6_PIN_D6, OUTPUT);
  64.     pinMode(myLCD1602_LCD1602_D7_PIN_D7, OUTPUT);
  65.  
  66.     pinMode(Bb_SDCardModule_SPI_PIN_CS_D10, OUTPUT);
  67.     SPI.begin();
  68.  
  69.     sensor_t* sensor = esp_camera_sensor_get();
  70.     ov5640.start(sensor);
  71.  
  72.     if (ov5640.focusInit() == 0) {
  73.         Serial.println("OV5640_Focus_Init Successful!");
  74.     }
  75.  
  76.     if (ov5640.autoFocusMode() == 0) {
  77.         Serial.println("OV5640_Auto_Focus Successful!");
  78.     }
  79. }
  80.  
  81. void loop()
  82. {
  83.     updateOutputs(); // Refresh output data
  84. }
  85.  
  86. void updateOutputs()
  87. {
  88.     digitalWrite(myLCD1602_LCD1602_D4_PIN_D4, myLCD1602_LCD1602_D4_PIN_D4_rawData);
  89.     digitalWrite(myLCD1602_LCD1602_D5_PIN_D5, myLCD1602_LCD1602_D5_PIN_D5_rawData);
  90.     digitalWrite(myLCD1602_LCD1602_D6_PIN_D6, myLCD1602_LCD1602_D6_rawData);
  91.     digitalWrite(myLCD1602_LCD1602_D7_PIN_D7, myLCD1602_LCD1602_D7_rawData);
  92. }
  93.  
  94. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement