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:08:04
- ********* 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 *****/
- /* 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 percentage);
- /***** 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*****/
- 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);
- // Initialize SIM900 module
- if (gsm_SIM900A_Serial.available()) {
- gsm_SIM900A_Serial.println("AT"); // Test AT command
- delay(100);
- }
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- checkForSMS(); // Check for incoming SMS
- }
- 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 (gsm_SIM900A_Serial.available()) {
- String sms = gsm_SIM900A_Serial.readString();
- if (sms.indexOf("NEW_SMS") != -1) { // Assuming "NEW_SMS" is part of the SMS content
- increasePotValue(5.0); // Increase pot value by 5%
- }
- }
- }
- void increasePotValue(float percentage)
- {
- // Assuming the potentiometer position is managed by a variable
- static uint8_t currentPosition = 0; // Initialize current position
- uint8_t increment = (uint8_t)(currentPosition * (percentage / 100.0));
- currentPosition += increment; // Increase position
- if (currentPosition > 255) currentPosition = 255; // Limit to max value
- pot_X9C10X_INC_PIN_D3_rawData = currentPosition; // Update the raw data for the potentiometer
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement