#define rxPin 0
#define txPin 1
#define buzz 4
#include <SoftwareSerial.h>
#include <string.h>
void setup()
{
Serial.begin (9600);
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(buzz, OUTPUT);
}
void loop()
{
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.print(voltage);
Serial.println(" volts");
if (voltage>=2)
{
digitalWrite(buzz, HIGH);
Serial.println(" cm");
Serial.println("AT");
delay(2000);
Serial.println("AT+CMGF=1");
delay(1500);
Serial.print("AT+CMGS=");
delay(2000);
Serial.print((char)34);
Serial.print("+9199XXXXX9490");
delay(4000);
Serial.println((char)34);
delay(2000);
Serial.println("SECURITY ALERT!");
delay(500);
Serial.println((char)26);
delay(9000);
return;
}
else
{
digitalWrite(buzz, LOW);
}
delay(500);
}
#define txPin 1
#define buzz 4
#include <SoftwareSerial.h>
#include <string.h>
void setup()
{
Serial.begin (9600);
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(buzz, OUTPUT);
}
void loop()
{
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.print(voltage);
Serial.println(" volts");
if (voltage>=2)
{
digitalWrite(buzz, HIGH);
Serial.println(" cm");
Serial.println("AT");
delay(2000);
Serial.println("AT+CMGF=1");
delay(1500);
Serial.print("AT+CMGS=");
delay(2000);
Serial.print((char)34);
Serial.print("+9199XXXXX9490");
delay(4000);
Serial.println((char)34);
delay(2000);
Serial.println("SECURITY ALERT!");
delay(500);
Serial.println((char)26);
delay(9000);
return;
}
else
{
digitalWrite(buzz, LOW);
}
delay(500);
}
No comments:
Post a Comment