Advertisement
pleasedontcode

Automated Pumping rev_01

Apr 26th, 2024
85
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: Automated Pumping
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-04-26 21:13:20
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* make a program that when the function is called 2 */
  21.     /* pumps activate start and stop at diferent times */
  22.     /* without using millis */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <L298NX2.h>    //https://github.com/AndreaLombardo/L298N
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31. void activatePumps(void);
  32. void updateOutputs(void);
  33.  
  34. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  35. const uint8_t pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13 = 13;
  36. const uint8_t pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14 = 14;
  37. const uint8_t pump12_L298NDualFull_BridgeMotorDriver_IN3_PIN_D17 = 17;
  38. const uint8_t pump12_L298NDualFull_BridgeMotorDriver_IN4_PIN_D18 = 18;
  39.  
  40. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  41. /***** used to store raw data *****/
  42. bool pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13_rawData = 0;
  43. bool pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14_rawData = 0;
  44. bool pump12_L298NDualFull_BridgeMotorDriver_IN3_PIN_D17_rawData = 0;
  45. bool pump12_L298NDualFull_BridgeMotorDriver_IN4_PIN_D18_rawData = 0;
  46.  
  47. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  48. /***** used to store data after characteristic curve transformation *****/
  49. float pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13_phyData = 0.0;
  50. float pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14_phyData = 0.0;
  51. float pump12_L298NDualFull_BridgeMotorDriver_IN3_PIN_D17_phyData = 0.0;
  52. float pump12_L298NDualFull_BridgeMotorDriver_IN4_PIN_D18_phyData = 0.0;
  53.  
  54. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  55. L298NX2 motor(pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13, pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14, pump12_L298NDualFull_BridgeMotorDriver_IN3_PIN_D17, pump12_L298NDualFull_BridgeMotorDriver_IN4_PIN_D18);
  56.  
  57. void setup(void)
  58. {
  59.     // put your setup code here, to run once:
  60.     pinMode(pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13, OUTPUT);
  61.     pinMode(pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14, OUTPUT);
  62.     pinMode(pump12_L298NDualFull_BridgeMotorDriver_IN3_PIN_D17, OUTPUT);
  63.     pinMode(pump12_L298NDualFull_BridgeMotorDriver_IN4_PIN_D18, OUTPUT);
  64. }
  65.  
  66. void loop(void)
  67. {
  68.     // put your main code here, to run repeatedly:
  69.     activatePumps(); // Activate pumps
  70. }
  71.  
  72. void activatePumps()
  73. {
  74.     // Activate pumps at different times
  75.     pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13_rawData = 1;
  76.     updateOutputs();
  77.     delay(1000); // Delay for 1 second
  78.     pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13_rawData = 0;
  79.  
  80.     pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14_rawData = 1;
  81.     updateOutputs();
  82.     delay(1000); // Delay for 1 second
  83.     pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14_rawData = 0;
  84. }
  85.  
  86. void updateOutputs()
  87. {
  88.     digitalWrite(pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13, pump12_L298NDualFull_BridgeMotorDriver_IN1_PIN_D13_rawData);
  89.     digitalWrite(pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14, pump12_L298NDualFull_BridgeMotorDriver_IN2_PIN_D14_rawData);
  90.     digitalWrite(pump12_L298NDualFull_BridgeMotorDriver_IN3_PIN_D17, pump12_L298NDualFull_BridgeMotorDriver_IN3_PIN_D17_rawData);
  91.     digitalWrite(pump12_L298NDualFull_BridgeMotorDriver_IN4_PIN_D18, pump12_L298NDualFull_BridgeMotorDriver_IN4_PIN_D18_rawData);
  92. }
  93.  
  94. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement