Advertisement
pleasedontcode

Arduino Setup rev_202

Jan 15th, 2024
57
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: Arduino Setup
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-01-15 14:36:10
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* if button is pressed so set out to 128. */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* read gps from spi and generate sinusoide signal if */
  23.     /* position is moving. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h>
  28. #include <EasyButton.h>
  29. #include <DS18B20.h>
  30. #include <SPI.h>
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35. void updateOutputs(void);
  36. void readGPS(void);
  37.  
  38. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  39. const uint8_t butt_PushButton_PIN_D4 = 4;
  40. const uint8_t ditpullup_PIN_D14 = 14;
  41. const uint8_t ditpulldown_PIN_D16 = 16;
  42. const uint8_t temp_DS18B20_DQ_PIN_D13 = 13;
  43.  
  44. /***** DEFINITION OF DAC OUTPUT PINS *****/
  45. const uint8_t out_PIN_D25 = 25;
  46.  
  47. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  48. /***** used to store raw data *****/
  49. uint8_t out_PIN_D25_rawData = 0;
  50.  
  51. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  52. /***** used to store data after characteristic curve transformation *****/
  53. float out_PIN_D25_phyData = 0.0;
  54.  
  55. /***** GPS VARIABLES *****/
  56. const uint8_t spi_SCLK_PIN_D18 = 18;
  57. const uint8_t spi_MISO_PIN_D19 = 19;
  58. const uint8_t spi_MOSI_PIN_D23 = 23;
  59. const uint8_t spi_CS_PIN_D5 = 5;
  60. const uint8_t spi_RST_PIN_D17 = 17;
  61.  
  62. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  63. EasyButton pushButton(butt_PushButton_PIN_D4); // Instance of the EasyButton class
  64. DS18B20 ds(temp_DS18B20_DQ_PIN_D13); // Instance of the DS18B20 class
  65.  
  66. void setup(void)
  67. {
  68.   // put your setup code here, to run once:
  69.   pinMode(butt_PushButton_PIN_D4, INPUT_PULLUP);
  70.   pinMode(ditpullup_PIN_D14, INPUT_PULLUP);
  71.   pinMode(ditpulldown_PIN_D16, INPUT_PULLDOWN);
  72.   pinMode(temp_DS18B20_DQ_PIN_D13, INPUT);
  73.  
  74.   pushButton.begin(); // Initialize the pushButton object
  75.  
  76.   SPI.begin(spi_SCLK_PIN_D18, spi_MISO_PIN_D19, spi_MOSI_PIN_D23, spi_CS_PIN_D5); // Initialize SPI communication
  77.   pinMode(spi_RST_PIN_D17, OUTPUT);
  78.   digitalWrite(spi_RST_PIN_D17, HIGH); // Set RST pin to high
  79. }
  80.  
  81. void loop(void)
  82. {
  83.   // put your main code here, to run repeatedly:
  84.   updateOutputs(); // Refresh output data
  85.   readGPS(); // Read GPS data
  86. }
  87.  
  88. void updateOutputs(void)
  89. {
  90.   // Implement the logic for updating the output data
  91.   // based on the system requirements
  92.   // For example, if button is pressed, set out to 128
  93.   if (pushButton.read() == true) {
  94.     out_PIN_D25_rawData = 128;
  95.   } else {
  96.     out_PIN_D25_rawData = 0;
  97.   }
  98.  
  99.   // Implement the logic to update the DAC output
  100.   // For example, use analogWrite() function to set the output voltage
  101.   analogWrite(out_PIN_D25, out_PIN_D25_rawData);
  102. }
  103.  
  104. void readGPS(void)
  105. {
  106.   // Code to read GPS data from SPI and generate sinusoidal signal if position is moving
  107.   // Implement the system requirement logic here
  108. }
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement