What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

Patulong sa Code ko sa Arduino. Need para maka graduate!

Aeyroon

Addict
Established
Joined
May 6, 2016
Messages
331
Reaction score
67
patulong sa code ko.

gumagana pero hindi nag sesend ng text. tulong po kung madaming errors.


eto po code ko.

_________________________________________________________________________________________________________________________________________________________________________________________________________

#include <SoftwareSerial.h>
SoftwareSerial SIM900 (7,8);
String textForSMS;

int green = 2;
int yellow = 3;
int red = 4;

const int trigPin = 13;
const int echoPin = 12;

String f1001 = "+639516876908";
String f1002 = "+639516876908";
String f1003 = "+639516876908";

void setup() {

Serial.begin (9600);
SIM900.begin (9600);
Serial.println (" Logging time completed !");
delay (5000);

pinMode (trigPin, OUTPUT);
pinMode (echoPin, INPUT);
pinMode (green, OUTPUT);
pinMode (yellow, OUTPUT);
pinMode (red, OUTPUT);
}

void loop() {
long duration , distance;

digitalWrite (trigPin, LOW);
delayMicroseconds(2);

digitalWrite (trigPin, HIGH);
delayMicroseconds(10);

digitalWrite (trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 28;

Serial.print(distance);
Serial.println(" cm");
delay (1000);


if ((distance >= 110) && (distance <= 150)) {

digitalWrite ( red , HIGH );

textForSMS = "\n Water Level is now on Critical Level, I reccomended you to evacuate now ! Water Distance from Device:",distance, "cm";
sendsms(textForSMS, f1001);
Serial.println(textForSMS);

delay (1000);

sendsms(textForSMS, f1002);
Serial.println(textForSMS);

delay (1000);

sendsms(textForSMS, f1003);
Serial.println(textForSMS);

delay (10000);
}

else if ( distance >= 0 && distance <=150){

digitalWrite (red, HIGH);
digitalWrite (yellow, LOW);
digitalWrite (green, LOW);

Serial.print(distance);
Serial.println(" cm");

}

else if (distance ==260 && distance == 350){


textForSMS = "\nn Water Level is now on Average Level, a flood may happen today ! Water Distance from Device:",distance, "cm";
sendsms(textForSMS, f1001);
Serial.println(textForSMS);

delay (1000);

sendsms(textForSMS, f1002);
Serial.println(textForSMS);

delay (1000);

sendsms(textForSMS, f1003);
Serial.println(textForSMS);

delay (1000);
}

else if ( distance >= 151 && distance <= 350){

digitalWrite (red, LOW);
digitalWrite (yellow, HIGH);
digitalWrite (green, LOW);

Serial.print(distance);
Serial.println(" cm");

}


else if (distance == 151 && distance == 250){


textForSMS = "\n Water Level is now on Average Level, there is a flood , Recommended to evacuate! Water Distance from Device: ",distance, "cm";
sendsms(textForSMS, f1001);
Serial.println(textForSMS);

delay (1000);

sendsms(textForSMS, f1002);
Serial.println(textForSMS);

delay (1000);

sendsms(textForSMS, f1003);
Serial.println(textForSMS);

delay (1000);
}



else if (distance ==351 && distance == 400){

textForSMS = "\n Water Level is on Good Level, there is no flood today! Water Distance from Device: ",distance, "cm";
sendsms(textForSMS, f1001);
Serial.println(textForSMS);

delay (1000);

sendsms(textForSMS, f1002);
Serial.println(textForSMS);

delay (1000);

sendsms(textForSMS, f1003);
Serial.println(textForSMS);

delay (1000);

}

else if ( distance >= 351 && distance <=500){

digitalWrite (red, LOW);
digitalWrite (yellow, LOW);
digitalWrite (green, HIGH);

Serial.print(distance);
Serial.println(" cm");

}


else
{
Serial.println("_________");
}

}


void sendsms(String message, String number)
{

String mnumber = "AT + CMGS = \""+number+"\"";
SIM900.print ("AT+CMGF=1\r");
delay (1000);
SIM900.println(mnumber);
delay (1000);
SIM900.println(message);
delay (1000);
SIM900.println((char)26);
delay (1000);
SIM900.println();
delay (1000);

}
 

Amhar

Addict
It might be from the sim/hardware itself or some of the gsm variables ang may problema kaya ayaw mag send.
May kaklasi ako na sim nya ching chong. Namomobrelama sya dahil hindi ng sesend ng sms pag lumindol. Niloadan lang nya ang sim nya kaya ganon. Kung swabi naman yung components o walang sira, load lang.
 

Aeyroon

Addict
May kaklasi ako na sim nya ching chong. Namomobrelama sya dahil hindi ng sesend ng sms pag lumindol. Niloadan lang nya ang sim nya kaya ganon. Kung swabi naman yung components o walang sira, load lang.
may load naman po paps
 

supawix098

Journeyman
tinry ko na din yung AT command para mag send ng sms. ganyan talaga lalabas
Hmm di ko rin kasi masasabing sira ang may problema sa GSM module mo since di ko naman nakikita, pero sa tingin ko settings lang yan. Check mo manual if meron ka, or download mo nalang base sa model nyan. Maraming pwedeng reason kaya nag e-error yan paps pwedeng sa length din ng text na binabato mo kasi may limit yan.
 

Aeyroon

Addict
Hmm di ko rin kasi masasabing sira ang may problema sa GSM module mo since di ko naman nakikita, pero sa tingin ko settings lang yan. Check mo manual if meron ka, or download mo nalang base sa model nyan. Maraming pwedeng reason kaya nag e-error yan paps pwedeng sa length din ng text na binabato mo kasi may limit yan.
hahaha tanggapin nalang na babagsak. deadline na bukas hahaha. byebye graduate hahahah.

tingin ko sa module to. bili nalang siguro ako ng bago.
 

Online statistics

Members online
2,013
Guests online
2,036
Total visitors
4,049

Forum statistics

Threads
847,315
Messages
15,010,571
Members
1,367,892
Top