Hai...
Sorry my english not good,
I have problem with my project.i create the project for read pulse in totalizer and send the result totaliser via sim900a.
But before i create script for pulsein the sim900a can send the message normally.after i create script pulsein the sim900a cannot send the message..
This my script :
#include <SoftwareSerial.h>
#include <EEPROM.h>
SoftwareSerial SIM900(2, 3);
char incoming_char=0;
int in = 8;
int out = 13;
int val = 0;
float count ;
unsigned long duration;
void setup()
{
Serial.begin(9600); // for serial monitor
SIM900.begin(9600); // for GSM shield
SIM900power(); // turn on shield
delay(2000); // give time to log on to network.
SIM900.print("AT+CMGF=1\r\n"); // set SMS mode to text
Serial.print("AT+CMGF=1\r\n");
Serial.println(SIM900.read());
delay(1000);
SIM900.print("AT+CNMI=2,2,0,0,0\r\n");
Serial.print("AT+CNMI=2,2,0,0,0\r\n");
Serial.print(SIM900.read());
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(1000);
SIM900.print("AT+CMGD=1,4\r\n");
Serial.print("AT+CMGD=1,4\r\n");
Serial.println(SIM900.read());
delay(1000);
Serial.println("READY....!!!");
//pulse_in();
}
void SendMessage()
{
SIM900.println("AT+CMGS=\"+6285862713774\"\r");
Serial.println("\rAT+CMGS=\"+6285862713774\"\r");
delay(2000);
SIM900.println("Totaliser penjualan akan dikirim");
Serial.println("Totaliser penjualan akan dikirim");
delay(2000);
SIM900.println((char)26);
Serial.println((char)26);
delay(2000);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(2000);
}
void pulse_in()
{
if(duration = pulseIn(in, LOW))
{
digitalWrite(out, HIGH);
Serial.println(count/10);
count++;
EEPROM.write(val,count);
delay (180);
}
else
{
digitalWrite(out, LOW);
//Serial.println(count/10);
delay(200);
EEPROM.write(val,count);
delay (180);
}
//EEPROM.write(val,count);
delay(200);
cli();
}
void loop()
{
pulse_in();
delay(1000);
// Now we simply display any text that the GSM shield sends out on the serial monitor
if(SIM900.available() >0)
{
incoming_char=SIM900.read(); //Get the character from the cellular serial port.
if (incoming_char == 'T')
{
delay(1000);
incoming_char=SIM900.read();
if(incoming_char == 'O')
{
delay(1000);
incoming_char=SIM900.read();
if(incoming_char == 'T')
{
delay(1000);
incoming_char=SIM900.read();
if(incoming_char == 'A')
{
delay(1000);
incoming_char=SIM900.read();
if(incoming_char == 'L')
{
delay(1000);
Serial.println("\rSMS Sending....\r"); //Print the incoming character to the terminal.
SendMessage();
}
}
}
}
}
}
}
I read at book its problem with interupts..but i not understand,so can any one help me.thx