hello all,
i wrote code send 1 sms if input high , , if low , high again,an sms sent,but code,nothing happened,just when turn gprs on,an sms sent , nothing happened again.
thank helping in advance.
i wrote code send 1 sms if input high , , if low , high again,an sms sent,but code,nothing happened,just when turn gprs on,an sms sent , nothing happened again.
thank helping in advance.
code: [select]
#include<softwareserial.h>
softwareserial sim900(7, 8);
#include <softwareserial.h>
#include "timerone.h"
const int di = 2;
const int dt = 3;
const int dgp1 = 4;
const int dgp2 = 5;
const long interval = 5000000; // in microseconds
int value1 = 0;
int value2 = 0;
int value3 = 0;
int value4 = 0;
int value1_old = 0;
int value2_old = 0;
int value3_old = 0;
int value4_old = 0;
boolean changed1 = false;
boolean changed2 = false;
boolean changed3 = false;
boolean changed4 = false;
void setup() {
pinmode(di, input);
pinmode(dt, input);
pinmode(dgp1, input);
pinmode(dgp2, input);
sim900.begin(19200);
timer1.initialize(interval);
timer1.attachinterrupt(isr_timer);
}
void isr_timer(){
if (changed1) {
sendsms1();
changed1 = false;
}
if (changed2) {
sendsms2();
changed2 = false;
}
if (changed3) {
sendsms3();
changed3 = false;
}
if (changed4) {
sendsms4();
changed4 = false;
}
}
void loop() {
value1 = digitalread (di);
value2 = digitalread (dt);
value3 = digitalread (dgp1);
value4 = digitalread (dgp2);
if (value1 != value1_old && value1 == high){
changed1 = true;
value1_old = value1;
}
if (value2 != value2_old && value2 == high){
changed2 = true;
value2_old = value2;
}
if (value3 != value3_old && value3 == high){
changed3 = true;
value3_old = value3;
}
if (value4 != value4_old && value4 == high){
changed4 = true;
value4_old = value4;
}
}
void sendsms1(){
sim900.print("at+cmgf=1\r");
delay(100);
sim900.println("at + cmgs = \"xxxxxxxxx\"");
delay(100);
sim900.println("steppe 85: error 1");
delay(100);
sim900.println((char)26);
delay(100);
sim900.println();
delay(5000);
}
void sendsms2(){
sim900.print("at+cmgf=1\r");
delay(100);
sim900.println("at + cmgs = \"xxxxxxxxx\"");
delay(100);
sim900.println("steppe 85: error 2");
delay(100);
sim900.println((char)26);
delay(100);
sim900.println();
delay(5000);
}
void sendsms3(){
sim900.print("at+cmgf=1\r");
delay(100);
sim900.println("at + cmgs = \"xxxxxxxxx\"");
delay(100);
sim900.println("steppe 85: error 3");
delay(100);
sim900.println((char)26);
delay(100);
sim900.println();
delay(5000);
}
void sendsms4(){
sim900.print("at+cmgf=1\r");
delay(100);
sim900.println("at + cmgs = \"xxxxxxxx\"");
delay(100);
sim900.println("steppe 85: error 4");
delay(100);
sim900.println((char)26);
delay(100);
sim900.println();
delay(5000);
}
Arduino Forum > Using Arduino > Programming Questions > problem of reading inputs to send SMS
arduino
Comments
Post a Comment