Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **SMS Control**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-12-05 23:31:01
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Develop a project utilizing the SIM900 GSM module */
- /* for sending and receiving SMS messages. Ensure the */
- /* SoftwareSerial interface on A0 and A1 is */
- /* configured for seamless communication and */
- /* implement basic command responses. */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* each time receive a new sms so increase pot value */
- /* of 5% */
- /****** END SYSTEM REQUIREMENTS *****/
- /********* User code review feedback **********
- #### Feedback 1 ####
- - initialize X9C10X library
- #### Feedback 2 ####
- - increasepotvalue using library.
- ********* User code review feedback **********/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h>
- #include <sim900.h> //https://github.com/nthnn
- #include <X9C10X.h> //https://github.com/RobTillaart/X9C10X
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs();
- void checkForSMS();
- void increasePotValue(float increment);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t pot_X9C10X_CS_PIN_D2 = 2;
- const uint8_t pot_X9C10X_INC_PIN_D3 = 3;
- const uint8_t pot_X9C10X_UD_PIN_D4 = 4;
- /***** DEFINITION OF Software Serial *****/
- const uint8_t gsm_SIM900A_Serial_PIN_SERIAL_TX_A0 = A0;
- const uint8_t gsm_SIM900A_Serial_PIN_SERIAL_RX_A1 = A1;
- SoftwareSerial gsm_SIM900A_Serial(gsm_SIM900A_Serial_PIN_SERIAL_RX_A1, gsm_SIM900A_Serial_PIN_SERIAL_TX_A0);
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool pot_X9C10X_CS_PIN_D2_rawData = 0;
- bool pot_X9C10X_INC_PIN_D3_rawData = 0;
- bool pot_X9C10X_UD_PIN_D4_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float pot_X9C10X_CS_PIN_D2_phyData = 0.0;
- float pot_X9C10X_INC_PIN_D3_phyData = 0.0;
- float pot_X9C10X_UD_PIN_D4_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Create an instance of the SIM900 class
- SIM900 gsmModule(&gsm_SIM900A_Serial);
- // Create an instance of the X9C10X class
- X9C10X potentiometer;
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(pot_X9C10X_CS_PIN_D2, OUTPUT);
- pinMode(pot_X9C10X_INC_PIN_D3, OUTPUT);
- pinMode(pot_X9C10X_UD_PIN_D4, OUTPUT);
- gsm_SIM900A_Serial.begin(9600);
- gsmModule.handshake(); // Initialize GSM module
- // Initialize the potentiometer
- potentiometer.begin(pot_X9C10X_INC_PIN_D3, pot_X9C10X_UD_PIN_D4, pot_X9C10X_CS_PIN_D2);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- checkForSMS(); // Check for incoming SMS
- updateOutputs(); // Refresh output data
- }
- void updateOutputs()
- {
- digitalWrite(pot_X9C10X_CS_PIN_D2, pot_X9C10X_CS_PIN_D2_rawData);
- digitalWrite(pot_X9C10X_INC_PIN_D3, pot_X9C10X_INC_PIN_D3_rawData);
- digitalWrite(pot_X9C10X_UD_PIN_D4, pot_X9C10X_UD_PIN_D4_rawData);
- }
- void checkForSMS()
- {
- if (gsmModule.isCardReady())
- {
- String message = gsmModule.getResponse(); // Get the SMS message
- if (message.length() > 0) // If a new SMS is received
- {
- increasePotValue(5.0); // Increase potentiometer value by 5%
- }
- }
- }
- void increasePotValue(float increment)
- {
- // Increase the potentiometer value by the specified increment
- potentiometer.incr(); // Use the library function to increase the potentiometer value
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement