Advertisement
pleasedontcode

"Pin Setup" rev_01

Feb 1st, 2024
62
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: "Pin Setup"
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-02-01 13:31:49
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* turn on DO0 when DI0 as true, turn on DO1 when DI1 */
  21.     /* as true */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Adafruit_MAX31865.h>    //https://github.com/adafruit/Adafruit_MAX31865
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30. void updateOutputs(void);
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t DI0_PushButton_PIN_D14    = 14;
  34. const uint8_t DI1_PushButton_PIN_D16    = 16;
  35.  
  36. /***** DEFINITION OF ANALOG INPUT PINS *****/
  37. const uint8_t AI0_Potentiometer_Vout_PIN_D4    = 4;
  38.  
  39. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  40. const uint8_t DO0_LED_PIN_D17    = 17;
  41. const uint8_t DO1_LED_PIN_D18    = 18;
  42.  
  43. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  44. /***** used to store raw data *****/
  45. bool    DO0_LED_PIN_D17_rawData    = 0;
  46. bool    DO1_LED_PIN_D18_rawData    = 0;
  47.  
  48. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  49. /***** used to store data after characteristic curve transformation *****/
  50. float    DO0_LED_PIN_D17_phyData    = 0.0;
  51. float    DO1_LED_PIN_D18_phyData    = 0.0;
  52.  
  53. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  54. Adafruit_MAX31865 max31865_sensor(10, 11, 12, 13); // Create instance of Adafruit_MAX31865 class
  55.  
  56. void setup(void)
  57. {
  58.     // put your setup code here, to run once:
  59.     pinMode(DI0_PushButton_PIN_D14,    INPUT_PULLUP);
  60.     pinMode(DI1_PushButton_PIN_D16,    INPUT_PULLUP);
  61.     pinMode(AI0_Potentiometer_Vout_PIN_D4,    INPUT);
  62.  
  63.     pinMode(DO0_LED_PIN_D17,     OUTPUT);
  64.     pinMode(DO1_LED_PIN_D18,     OUTPUT);
  65.  
  66.     // Initialize the MAX31865 sensor
  67.     max31865_sensor.begin(MAX31865_3WIRE); // Initialize the sensor with 3-wire configuration
  68. }
  69.  
  70. void loop(void)
  71. {
  72.     // put your main code here, to run repeatedly:
  73.     bool DI0_Status = digitalRead(DI0_PushButton_PIN_D14); // Read the status of DI0
  74.     bool DI1_Status = digitalRead(DI1_PushButton_PIN_D16); // Read the status of DI1
  75.  
  76.     // Update output raw data based on input status
  77.     DO0_LED_PIN_D17_rawData = DI0_Status;
  78.     DO1_LED_PIN_D18_rawData = DI1_Status;
  79.  
  80.     updateOutputs(); // Refresh output data
  81. }
  82.  
  83. void updateOutputs()
  84. {
  85.     digitalWrite(DO0_LED_PIN_D17, DO0_LED_PIN_D17_rawData);
  86.     digitalWrite(DO1_LED_PIN_D18, DO1_LED_PIN_D18_rawData);
  87. }
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement