FISHERMAN ASSISTING AND RESCUE SYSTEM

Photo of author

By Jackson Taylor

CIRCUIT

PROGRAM
#include <Servo.h>
 Servo myservo;  // create servo object to control a servo
int a=0,y=0,duration;
void setup()
{
   pinMode(2, INPUT);   digitalWrite(2, HIGH);//switch
pinMode(8, OUTPUT);   digitalWrite(8, LOW);//buzzer
  displayinit();
  displaytest();
  myservo.attach(3);
  usinit();
  serialstart();
}
void loop()
{
  swwater ();
myservo.write(0); delay(1000);  us();
if(a>10 && a<20){digitalWrite(A4, HIGH);  delay(100);}  else digitalWrite(A4, LOW);
  swwater ();
myservo.write(20); delay(1000); us();
if(a>10 && a<20){digitalWrite(A3, HIGH);  delay(100);}  else digitalWrite(A3, LOW);
  swwater ();
myservo.write(40); delay(1000);  us();
if(a>10 && a<20){digitalWrite(A2, HIGH);  delay(100);}  else digitalWrite(A2, LOW);
myservo.write(60); delay(1000); us();
if(a>10 && a<20){digitalWrite(A1, HIGH);  delay(100);}  else digitalWrite(A1, LOW);
  swwater ();
myservo.write(80); delay(1000);  us();
if(a>10 && a<20){digitalWrite(A0, HIGH);  delay(100);}  else digitalWrite(A0, LOW);
  swwater ();
myservo.write(100); delay(1000); us();
if(a>10 && a<20){digitalWrite(13, HIGH);  delay(100);}  else digitalWrite(13, LOW);
  swwater ();
myservo.write(120); delay(1000);  us();
if(a>10 && a<20){digitalWrite(12, HIGH);  delay(100);}  else digitalWrite(12, LOW);
  swwater ();
myservo.write(140); delay(1000); us();
if(a>10 && a<20){digitalWrite(11, HIGH);  delay(100);}  else digitalWrite(11, LOW);
  swwater ();
myservo.write(160); delay(1000);  us();
if(a>10 && a<20){digitalWrite(10, HIGH);  delay(100);}  else digitalWrite(10, LOW);
  swwater ();
myservo.write(180); delay(1500); us();
if(a>10 && a<20){digitalWrite(9, HIGH);  delay(100);}  else digitalWrite(9, LOW);
  /*
   */
}
void swwater (void)
{
  int z= analogRead(A5);
  if(z>200){if(y==0)message();y=1;digitalWrite(8, HIGH);}
  int x=digitalRead(2);
  if(x==0){digitalWrite(8, HIGH);}
  if(x==1 && (z<200)){digitalWrite(8, LOW);}
}
void message(void)
{
Serial.print(“AT+CMGS=”);
Serial.write(0X22);
Serial.print(“98952”);
Serial.print(“41319”);
Serial.write(0X22);
Serial.write(0xd);
delay(1000);
Serial.print(“boat “);
Serial.print(“on “);
Serial.print(“danger”);
for(int v=0;v<25;v++){Serial.write(Serial.read());}
Serial.write(0x1a);
}
void serialstart(void)
{
 Serial.begin(9600);
 Serial.print(“AT+CMGF=1”);
 Serial.write(0xd);
}
void displayinit(void)
{
   pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT);
   pinMode(13, OUTPUT); pinMode(A0, OUTPUT); pinMode(A1, OUTPUT); pinMode(A2, OUTPUT);
   pinMode(A3, OUTPUT); pinMode(A4, OUTPUT);
}
void displaytest(void)
{
 digitalWrite(9, HIGH); digitalWrite(10, HIGH); digitalWrite(11, HIGH); digitalWrite(12, HIGH);
 digitalWrite(13, HIGH); digitalWrite(A0, HIGH); digitalWrite(A1, HIGH); digitalWrite(A2, HIGH);
 digitalWrite(A3, HIGH); digitalWrite(A4, HIGH);
delay(1000);
 digitalWrite(9, LOW); digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(12, LOW);
 digitalWrite(13, LOW); digitalWrite(A0, LOW); digitalWrite(A1, LOW); digitalWrite(A2, LOW);
 digitalWrite(A3, LOW); digitalWrite(A4, LOW);
}
void usinit(void)
{
pinMode(4, OUTPUT);// Trigger Pin
 pinMode(5, INPUT);// Echo Pin
 digitalWrite(4  , LOW);
}
void us(void)
{
 digitalWrite(4, HIGH); //sends signal 10 us to excite ultra sonic sensor
 delayMicroseconds(10);
 digitalWrite(4, LOW);
 duration = pulseIn(5, HIGH);//reads  duartion pulse in Microseconds
 a = duration/58;
}