SlideShare a Scribd company logo
1 of 4
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);//10 tx 9 rx
void setup() {
pinMode(A0,INPUT);
pinMode(6,OUTPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(A3,INPUT);
pinMode(5,OUTPUT);
mySerial.begin(9600);
Serial.begin(9600);
}
void loop()
{
int ldr1value=analogRead(A0); // reading inputs from sensors ldr1
int ldr2value=analogRead(A1); //ldr2
int irvalue=analogRead(A2); // IR
int ldr3value=analogRead(A3);
int f=0;
int ldrth=30; //ldr1 threshold
int ld2th=30;
Serial.print("n");
Serial.print("sensor=");
Serial.print(ldr1value);
Serial.print("n");
Serial.print("ir=");
Serial.print(irvalue);
Serial.print("n");
Serial.print("ld2=");
Serial.print(ldr2value);
Serial.print("n");
Serial.print("ld3=");
Serial.print(ldr3value);
delay(100);
if(ldr1value<ldrth) //room daylight 154//room night tubelight 83
{
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
while(ldr2value<ld2th || ldr3value<ld2th)//daylight 130/room 30
{
f++;
if(f==1)
{
if(ldr2value<ld2th)
{
Serial.println("dialling 1...");
SendMessagep1();
digitalWrite(6,HIGH);
}
else
if(ldr3value<ld2th)
{
Serial.println("dialling 2...");
SendMessagep2();
digitalWrite(5,HIGH);
}
Serial.println("message sent!!!");
delay(10);
}
if(ldr2value<ld2th)
{
if(irvalue<500 && ldr1value<ldrth)
{
digitalWrite(6,HIGH);
digitalWrite(6,LOW);
delay(.1);
}
else
digitalWrite(6,HIGH);
irvalue=analogRead(A2);
ldr1value=analogRead(A0);
}
else
if(ldr3value<ld2th)
{
if(irvalue<500 && ldr1value<ldrth)
{
digitalWrite(5,HIGH);
digitalWrite(5,LOW);
delay(.1);
}
else
digitalWrite(5,HIGH);
}
irvalue=analogRead(A2);
ldr1value=analogRead(A0);
ldr2value=analogRead(A1);
ldr3value=analogRead(A3);
Serial.println(f);
}
f=0;
while(irvalue<500 && ldr1value<ldrth)
{
f=0;
Serial.print("ir=");
Serial.print(irvalue);
Serial.print("n");
digitalWrite(5,HIGH);//pin 5 connected to brightness control
component
digitalWrite(5,LOW);
delay(.1);
digitalWrite(6,HIGH);
digitalWrite(6,LOW);
delay(.1);
irvalue=analogRead(A2);
ldr1value=analogRead(A0);
ldr2value=analogRead(A1);
ldr3value=analogRead(A3);
while(ldr2value<ld2th || ldr3value<ld2th)//daylight 130/room 30
{
f++;
Serial.println("dialling...");
if(f==1)
{
if(ldr2value<ld2th)
SendMessagep1();
else
if(ldr3value<ld2th)
SendMessagep2();
Serial.println("message sent!!!");
delay(10);
}
ldr2value=analogRead(A1);
ldr3value=analogRead(A3);
if(ldr2value<ld2th)
{
if(irvalue<500 && ldr1value<ldrth)
{
digitalWrite(6,HIGH);
digitalWrite(6,LOW);
delay(.1);
}
else
digitalWrite(6,HIGH);
irvalue=analogRead(A2);
ldr1value=analogRead(A0);
}
else
if(ldr3value<ld2th)
{
if(irvalue<500 && ldr1value<ldrth)
{
digitalWrite(5,HIGH);
digitalWrite(5,LOW);
delay(.1);
}
else
digitalWrite(5,HIGH);
irvalue=analogRead(A2);
ldr1value=analogRead(A0);
}
Serial.println(f);
ldr2value=analogRead(A1);
ldr3value=analogRead(A3);
}
}
}
else
{
digitalWrite(5,LOW);
digitalWrite(6,LOW);
}
}
void SendMessagep1()
{
mySerial.println("AT+CMGF=1");
delay(1000);
mySerial.println("AT+CMGS="+919495810714"r");
delay(1000);
mySerial.println("https://www.google.com/maps/preview/@9.5503466,76.612264,17.44
z post no 1 complaint");
delay(1000);
mySerial.println((char)26);
delay(1000);
}
void SendMessagep2()
{
mySerial.println("AT+CMGF=1");
delay(1000);
mySerial.println("AT+CMGS="+919495810714"r");
delay(1000);
mySerial.println("https://www.google.com/maps/preview/@9.5503466,76.612264,17.44
z post no 2 complaint");
delay(1000);
mySerial.println((char)26);
delay(1000);
}

More Related Content

What's hot

Create your first model for a simple logic circuit
Create your first model for a simple logic circuitCreate your first model for a simple logic circuit
Create your first model for a simple logic circuitMohamed Samy
 
Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/OJune-Hao Hou
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical FileSoumya Behera
 
All VLSI programs
All VLSI programsAll VLSI programs
All VLSI programsGouthaman V
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical fileArchita Misra
 
Device Modeling of Oscillator using PSpice
Device Modeling of Oscillator using PSpiceDevice Modeling of Oscillator using PSpice
Device Modeling of Oscillator using PSpiceTsuyoshi Horigome
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IOT Academy
 
Building Hierarchy
Building HierarchyBuilding Hierarchy
Building HierarchyMohamed Samy
 
Digital system design lab manual
Digital system design lab manualDigital system design lab manual
Digital system design lab manualSanthosh Poralu
 

What's hot (20)

Create your first model for a simple logic circuit
Create your first model for a simple logic circuitCreate your first model for a simple logic circuit
Create your first model for a simple logic circuit
 
Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/O
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 
Compteur ARDUINO
Compteur ARDUINOCompteur ARDUINO
Compteur ARDUINO
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical File
 
All VLSI programs
All VLSI programsAll VLSI programs
All VLSI programs
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
 
Vhdl lab manual
Vhdl lab manualVhdl lab manual
Vhdl lab manual
 
Modeling FSMs
Modeling FSMsModeling FSMs
Modeling FSMs
 
Device Modeling of Oscillator using PSpice
Device Modeling of Oscillator using PSpiceDevice Modeling of Oscillator using PSpice
Device Modeling of Oscillator using PSpice
 
Vhdlbputspdas
VhdlbputspdasVhdlbputspdas
Vhdlbputspdas
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
 
Building Hierarchy
Building HierarchyBuilding Hierarchy
Building Hierarchy
 
Digital system design lab manual
Digital system design lab manualDigital system design lab manual
Digital system design lab manual
 
Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
 
Dsd prac1
Dsd prac1Dsd prac1
Dsd prac1
 
Programming arduino makeymakey
Programming arduino makeymakeyProgramming arduino makeymakey
Programming arduino makeymakey
 
Vend with ff
Vend with ffVend with ff
Vend with ff
 
67WS Seminar Event
67WS Seminar Event67WS Seminar Event
67WS Seminar Event
 
Appsec obfuscator reloaded
Appsec obfuscator reloadedAppsec obfuscator reloaded
Appsec obfuscator reloaded
 

Similar to Arduino code

第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -Wataru Kani
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle SensorJoeCritt
 
Termòmetre The Arduino Starter Kit
Termòmetre The Arduino Starter KitTermòmetre The Arduino Starter Kit
Termòmetre The Arduino Starter KitLaia P
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINOS Ayub
 
第一回 冬のスイッチ大勉強会 - XBee編 -
第一回 冬のスイッチ大勉強会 - XBee編 -第一回 冬のスイッチ大勉強会 - XBee編 -
第一回 冬のスイッチ大勉強会 - XBee編 -Wataru Kani
 
Vechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptVechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptsatish 486
 
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdfalltiusind
 
Lec2.ppt
Lec2.pptLec2.ppt
Lec2.pptfgjf1
 
Program flowchart
Program flowchartProgram flowchart
Program flowchartSowri Rajan
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuatorsEueung Mulyana
 
C programs
C programsC programs
C programsMinu S
 
Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+Eueung Mulyana
 
5 c control statements looping
5  c control statements looping5  c control statements looping
5 c control statements loopingMomenMostafa
 

Similar to Arduino code (20)

第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle Sensor
 
Termòmetre The Arduino Starter Kit
Termòmetre The Arduino Starter KitTermòmetre The Arduino Starter Kit
Termòmetre The Arduino Starter Kit
 
FINISHED_CODE
FINISHED_CODEFINISHED_CODE
FINISHED_CODE
 
Arduino Programming
Arduino ProgrammingArduino Programming
Arduino Programming
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
 
Arduino.pptx
Arduino.pptxArduino.pptx
Arduino.pptx
 
第一回 冬のスイッチ大勉強会 - XBee編 -
第一回 冬のスイッチ大勉強会 - XBee編 -第一回 冬のスイッチ大勉強会 - XBee編 -
第一回 冬のスイッチ大勉強会 - XBee編 -
 
4x4
4x44x4
4x4
 
Vechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptVechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor ppt
 
Arduino Code
Arduino CodeArduino Code
Arduino Code
 
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 
R tist
R tistR tist
R tist
 
Lec2.ppt
Lec2.pptLec2.ppt
Lec2.ppt
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
 
C programs
C programsC programs
C programs
 
Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+
 
5 c control statements looping
5  c control statements looping5  c control statements looping
5 c control statements looping
 

Recently uploaded

SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organizationchnrketan
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdfAkritiPradhan2
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfisabel213075
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewsandhya757531
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labsamber724300
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProRay Yuan Liu
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Romil Mishra
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfDrew Moseley
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectGayathriM270621
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 

Recently uploaded (20)

SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organization
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdf
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overview
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labs
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision Pro
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdf
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subject
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 

Arduino code

  • 1. #include <SoftwareSerial.h> SoftwareSerial mySerial(9, 10);//10 tx 9 rx void setup() { pinMode(A0,INPUT); pinMode(6,OUTPUT); pinMode(A1,INPUT); pinMode(A2,INPUT); pinMode(A3,INPUT); pinMode(5,OUTPUT); mySerial.begin(9600); Serial.begin(9600); } void loop() { int ldr1value=analogRead(A0); // reading inputs from sensors ldr1 int ldr2value=analogRead(A1); //ldr2 int irvalue=analogRead(A2); // IR int ldr3value=analogRead(A3); int f=0; int ldrth=30; //ldr1 threshold int ld2th=30; Serial.print("n"); Serial.print("sensor="); Serial.print(ldr1value); Serial.print("n"); Serial.print("ir="); Serial.print(irvalue); Serial.print("n"); Serial.print("ld2="); Serial.print(ldr2value); Serial.print("n"); Serial.print("ld3="); Serial.print(ldr3value); delay(100); if(ldr1value<ldrth) //room daylight 154//room night tubelight 83 { digitalWrite(5,HIGH); digitalWrite(6,HIGH); while(ldr2value<ld2th || ldr3value<ld2th)//daylight 130/room 30 { f++; if(f==1) { if(ldr2value<ld2th) { Serial.println("dialling 1..."); SendMessagep1(); digitalWrite(6,HIGH); } else if(ldr3value<ld2th) { Serial.println("dialling 2..."); SendMessagep2(); digitalWrite(5,HIGH); } Serial.println("message sent!!!"); delay(10); }
  • 2. if(ldr2value<ld2th) { if(irvalue<500 && ldr1value<ldrth) { digitalWrite(6,HIGH); digitalWrite(6,LOW); delay(.1); } else digitalWrite(6,HIGH); irvalue=analogRead(A2); ldr1value=analogRead(A0); } else if(ldr3value<ld2th) { if(irvalue<500 && ldr1value<ldrth) { digitalWrite(5,HIGH); digitalWrite(5,LOW); delay(.1); } else digitalWrite(5,HIGH); } irvalue=analogRead(A2); ldr1value=analogRead(A0); ldr2value=analogRead(A1); ldr3value=analogRead(A3); Serial.println(f); } f=0; while(irvalue<500 && ldr1value<ldrth) { f=0; Serial.print("ir="); Serial.print(irvalue); Serial.print("n"); digitalWrite(5,HIGH);//pin 5 connected to brightness control component digitalWrite(5,LOW); delay(.1); digitalWrite(6,HIGH); digitalWrite(6,LOW); delay(.1); irvalue=analogRead(A2); ldr1value=analogRead(A0); ldr2value=analogRead(A1); ldr3value=analogRead(A3); while(ldr2value<ld2th || ldr3value<ld2th)//daylight 130/room 30 { f++; Serial.println("dialling..."); if(f==1) { if(ldr2value<ld2th) SendMessagep1(); else if(ldr3value<ld2th)
  • 3. SendMessagep2(); Serial.println("message sent!!!"); delay(10); } ldr2value=analogRead(A1); ldr3value=analogRead(A3); if(ldr2value<ld2th) { if(irvalue<500 && ldr1value<ldrth) { digitalWrite(6,HIGH); digitalWrite(6,LOW); delay(.1); } else digitalWrite(6,HIGH); irvalue=analogRead(A2); ldr1value=analogRead(A0); } else if(ldr3value<ld2th) { if(irvalue<500 && ldr1value<ldrth) { digitalWrite(5,HIGH); digitalWrite(5,LOW); delay(.1); } else digitalWrite(5,HIGH); irvalue=analogRead(A2); ldr1value=analogRead(A0); } Serial.println(f); ldr2value=analogRead(A1); ldr3value=analogRead(A3); } } } else { digitalWrite(5,LOW); digitalWrite(6,LOW); } } void SendMessagep1() { mySerial.println("AT+CMGF=1"); delay(1000); mySerial.println("AT+CMGS="+919495810714"r"); delay(1000); mySerial.println("https://www.google.com/maps/preview/@9.5503466,76.612264,17.44 z post no 1 complaint"); delay(1000); mySerial.println((char)26); delay(1000); }