Advertisement
pleasedontcode

**SMS Control** rev_02

Dec 5th, 2024
42
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: **SMS Control**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-05 23:02:04
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Develop a project utilizing the SIM900 GSM module */
  21.     /* for sending and receiving SMS messages. Ensure the */
  22.     /* SoftwareSerial interface on A0 and A1 is */
  23.     /* configured for seamless communication and */
  24.     /* implement basic command responses. */
  25. /****** SYSTEM REQUIREMENT 2 *****/
  26.     /* each time receive a new sms so increase pot value */
  27.     /* of 5% */
  28. /****** END SYSTEM REQUIREMENTS *****/
  29.  
  30. /* START CODE */
  31.  
  32. /****** DEFINITION OF LIBRARIES *****/
  33. #include <SoftwareSerial.h>
  34. #include <sim900.h> //https://github.com/nthnn
  35. #include <X9C10X.h> //https://github.com/RobTillaart/X9C10X
  36.  
  37. /****** FUNCTION PROTOTYPES *****/
  38. void setup(void);
  39. void loop(void);
  40. void updateOutputs();
  41. void checkForSMS();
  42.  
  43. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  44. const uint8_t pot_X9C10X_CS_PIN_D2      = 2;
  45. const uint8_t pot_X9C10X_INC_PIN_D3     = 3;
  46. const uint8_t pot_X9C10X_UD_PIN_D4      = 4;
  47.  
  48. /***** DEFINITION OF Software Serial *****/
  49. const uint8_t gsm_SIM900A_Serial_PIN_SERIAL_TX_A0       = A0;
  50. const uint8_t gsm_SIM900A_Serial_PIN_SERIAL_RX_A1       = A1;
  51. SoftwareSerial gsm_SIM900A_Serial(gsm_SIM900A_Serial_PIN_SERIAL_RX_A1, gsm_SIM900A_Serial_PIN_SERIAL_TX_A0);
  52.  
  53. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  54. /***** used to store raw data *****/
  55. bool    pot_X9C10X_CS_PIN_D2_rawData        = 0;
  56. bool    pot_X9C10X_INC_PIN_D3_rawData       = 0;
  57. bool    pot_X9C10X_UD_PIN_D4_rawData        = 0;
  58.  
  59. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  60. /***** used to store data after characteristic curve transformation *****/
  61. float   pot_X9C10X_CS_PIN_D2_phyData        = 0.0;
  62. float   pot_X9C10X_INC_PIN_D3_phyData       = 0.0;
  63. float   pot_X9C10X_UD_PIN_D4_phyData        = 0.0;
  64.  
  65. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  66.  
  67. void setup(void)
  68. {
  69.     // put your setup code here, to run once:
  70.  
  71.     pinMode(pot_X9C10X_CS_PIN_D2,    OUTPUT);
  72.     pinMode(pot_X9C10X_INC_PIN_D3,   OUTPUT);
  73.     pinMode(pot_X9C10X_UD_PIN_D4,    OUTPUT);
  74.  
  75.     gsm_SIM900A_Serial.begin(9600);
  76. }
  77.  
  78. void loop(void)
  79. {
  80.     // put your main code here, to run repeatedly:
  81.     updateOutputs(); // Refresh output data
  82.     checkForSMS();    // Check for incoming SMS
  83. }
  84.  
  85. void updateOutputs()
  86. {
  87.     digitalWrite(pot_X9C10X_CS_PIN_D2, pot_X9C10X_CS_PIN_D2_rawData);
  88.     digitalWrite(pot_X9C10X_INC_PIN_D3, pot_X9C10X_INC_PIN_D3_rawData);
  89.     digitalWrite(pot_X9C10X_UD_PIN_D4, pot_X9C10X_UD_PIN_D4_rawData);
  90. }
  91.  
  92. void checkForSMS()
  93. {
  94.     if (gsm_SIM900A_Serial.available()) {
  95.         String sms = gsm_SIM900A_Serial.readStringUntil('\n'); // Read SMS
  96.         // Process the SMS here (e.g., increase pot value by 5%)
  97.         pot_X9C10X_INC_PIN_D3_rawData = true; // Example action
  98.         // Increase the potentiometer value by 5%
  99.         // Assuming pot_X9C10X_INC_PIN_D3 is used to control the increment
  100.     }
  101. }
  102.  
  103. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement