Advertisement
pleasedontcode

"Digital Setup" rev_216

Jan 15th, 2024
86
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: "Digital Setup"
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-01-16 00:20:08
  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 <EasyButton.h>
  28. #include <DS18B20.h>
  29. #include <SPI.h>
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34. void updateOutputs(void);
  35.  
  36. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  37. const uint8_t butt_PushButton_PIN_D4 = 4;
  38. const uint8_t ditpullup_PIN_D14 = 14;
  39. const uint8_t ditpulldown_PIN_D16 = 16;
  40. const uint8_t temp_DS18B20_DQ_PIN_D13 = 13;
  41.  
  42. /***** DEFINITION OF DAC OUTPUT PINS *****/
  43. const uint8_t out_PIN_D25 = 25;
  44.  
  45. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  46. /***** used to store raw data *****/
  47. uint8_t out_PIN_D25_rawData = 0;
  48.  
  49. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  50. /***** used to store data after characteristic curve transformation *****/
  51. float out_PIN_D25_phyData = 0.0;
  52.  
  53. /****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
  54. EasyButton butt_PushButton(butt_PushButton_PIN_D4, true);
  55. DS18B20 tempSensor(temp_DS18B20_DQ_PIN_D13);
  56.  
  57. void setup(void)
  58. {
  59.   // put your setup code here, to run once:
  60.  
  61.   pinMode(butt_PushButton_PIN_D4, INPUT_PULLUP);
  62.   pinMode(ditpullup_PIN_D14, INPUT_PULLUP);
  63.   pinMode(ditpulldown_PIN_D16, INPUT_PULLDOWN);
  64.   pinMode(temp_DS18B20_DQ_PIN_D13, INPUT);
  65.  
  66.   // Initialize the button
  67.   butt_PushButton.begin();
  68.  
  69.   // Initialize SPI for GPS communication
  70.   SPI.begin();
  71. }
  72.  
  73. void loop(void)
  74. {
  75.   // put your main code here, to run repeatedly:
  76.  
  77.   butt_PushButton.read();
  78.  
  79.   // Check if the button is pressed
  80.   if (butt_PushButton.isPressed()) {
  81.     out_PIN_D25_rawData = 128; // Set output to 128
  82.   } else {
  83.     out_PIN_D25_rawData = 0; // Set output to 0
  84.   }
  85.  
  86.   // Read GPS data from SPI and check for movement
  87.   // If position is moving, generate sinusoidal signal
  88.  
  89.   // Update the outputs
  90.   updateOutputs();
  91. }
  92.  
  93. void updateOutputs(void)
  94. {
  95.   dacWrite(out_PIN_D25, out_PIN_D25_rawData);
  96. }
  97.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement