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: **System Control**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-11-22 15:43:35
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* 20*4 lcd i2c, ds3231 rtc, 3 switches to 3 outputs, */
- /* 1 switch to pump motor with low level and high */
- /* level input controls */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* 20*4 lcd i2c,, 3 switches to 3 separate outputs 1 */
- /* manual switch to pump motor with low level "motor */
- /* on" and high level "motor off" input controls, and */
- /* pump motor & 3 separate outputs are contolled by */
- /* timer alarm rtc ds3231 and sms sim 900A gsm modu */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #include <RTClib.h>
- #include <SoftwareSerial.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- // Constants for the LCD
- #define LCD_ADDRESS 0x27 // I2C address of the LCD
- #define LCD_COLUMNS 20
- #define LCD_ROWS 4
- // Pin definitions
- const int switch1Pin = 2; // Switch for output 1
- const int switch2Pin = 3; // Switch for output 2
- const int switch3Pin = 4; // Switch for output 3
- const int pumpSwitchPin = 5; // Manual switch for pump motor
- // Output pins
- const int output1Pin = 6; // Output 1
- const int output2Pin = 7; // Output 2
- const int output3Pin = 8; // Output 3
- const int pumpMotorPin = 9; // Pump motor control
- // Create instances of the libraries
- LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS);
- RTC_DS3231 rtc;
- SoftwareSerial gsm(10, 11); // RX, TX for GSM module
- void setup(void)
- {
- // Initialize the LCD
- lcd.begin(LCD_COLUMNS, LCD_ROWS);
- lcd.backlight();
- lcd.print("System Init...");
- // Initialize the RTC
- if (!rtc.begin()) {
- lcd.print("RTC Error!");
- while (1);
- }
- // Set up pin modes
- pinMode(switch1Pin, INPUT);
- pinMode(switch2Pin, INPUT);
- pinMode(switch3Pin, INPUT);
- pinMode(pumpSwitchPin, INPUT);
- pinMode(output1Pin, OUTPUT);
- pinMode(output2Pin, OUTPUT);
- pinMode(output3Pin, OUTPUT);
- pinMode(pumpMotorPin, OUTPUT);
- // Initialize GSM module
- gsm.begin(9600);
- }
- void loop(void)
- {
- // Read switch states
- bool switch1State = digitalRead(switch1Pin);
- bool switch2State = digitalRead(switch2Pin);
- bool switch3State = digitalRead(switch3Pin);
- bool pumpSwitchState = digitalRead(pumpSwitchPin);
- // Control outputs based on switch states
- digitalWrite(output1Pin, switch1State);
- digitalWrite(output2Pin, switch2State);
- digitalWrite(output3Pin, switch3State);
- // Control pump motor based on manual switch
- if (pumpSwitchState) {
- digitalWrite(pumpMotorPin, HIGH); // Motor ON
- } else {
- digitalWrite(pumpMotorPin, LOW); // Motor OFF
- }
- // Get current time from RTC
- DateTime now = rtc.now();
- lcd.setCursor(0, 1);
- lcd.print(now.year(), DEC);
- lcd.print('/');
- lcd.print(now.month(), DEC);
- lcd.print('/');
- lcd.print(now.day(), DEC);
- lcd.print(" ");
- lcd.print(now.hour(), DEC);
- lcd.print(':');
- lcd.print(now.minute(), DEC);
- lcd.print(':');
- lcd.print(now.second(), DEC);
- // Add any additional functionality here (e.g., timer alarms, SMS notifications)
- delay(1000); // Update every second
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement