Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #include <SoftwareSerial.h>
- SoftwareSerial SIM900A(2,3); // RX | TX
- // Connect the SIM900A TX to Arduino pin 2 RX.
- // Connect the SIM900A RX to Arduino pin 3 TX.
- char c = ' ';
- void setup()
- {
- // start th serial communication with the host computer
- Serial.begin(9600);
- while(!Serial);
- Serial.println("Arduino with SIM900A is ready");
- // start communication with the SIM900A in 9600
- SIM900A.begin(9600);
- Serial.println("SIM900A started at 9600");
- delay(1000);
- Serial.println("Setup Complete! SIM900A is Ready!");
- }
- void loop()
- {
- // Keep reading from SIM800 and send to Arduino Serial Monitor
- if (SIM900A.available())
- { c = SIM900A.read();
- Serial.write(c);}
- // Keep reading from Arduino Serial Monitor and send to SIM900A
- if (Serial.available())
- { c = Serial.read();
- SIM900A.write(c);
- }
- }
- */
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #include <SoftwareSerial.h>
- LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);
- SoftwareSerial SIM900A(10, 11);
- int analogValue;
- int LED_Pin = 13; // Set up the LED indicator
- int Sound_Pin = A0;
- int t = 548 ;
- void setup()
- {
- SIM900A.begin(9600); // Setting the baud rate of GSM Module
- Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
- Serial.println ("SIM900A Ready");
- delay(100);
- Serial.println ("Type s to send message or r to receive message");
- pinMode(LED_Pin, OUTPUT);
- SendMessage();
- lcd.begin();
- lcd.backlight();
- lcd.clear();
- }
- void loop()
- {
- analogValue = analogRead(Sound_Pin);
- Serial.println(analogValue);
- lcd.setCursor(3, 0);
- lcd.print("Sound level ");
- lcd.setCursor(8, 1);
- lcd.print(analogValue);
- delay(50);
- if (analogValue > t) // If higher than 8 is returned, then change state of boolean "toggle" to true, display analogValue to serial monitor and wait 200ms.
- // The higher the value in the above "if" statement, the less sensitive your clapper will be. Use the serial monitor to calibrate to your wanted sensitivity =D
- {
- SendMessage();
- Serial.println(analogValue);
- delay(200);
- }
- }
- void SendMessage()
- {
- Serial.println ("Sending Message");
- SIM900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
- delay(1000);
- Serial.println ("Set SMS Number");
- SIM900A.println("AT+CMGS=\"+966554418546\"\r"); //Mobile phone number to send message
- //540538259 SAFWAN 2
- //554418546 SAFWAN 1
- delay(1000);
- Serial.println ("Set SMS Content");
- SIM900A.println("Be quiet");// Messsage content
- delay(100);
- Serial.println ("Finish");
- SIM900A.println((char)26);// ASCII code of CTRL+Z
- delay(1000);
- Serial.println ("Message has been sent ->SMS Selesai dikirim");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement