Pages: [1]   Go Down
Author Topic: ERROR  (Read 345 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HERE'S my code
Code:
#include <SoftwareSerial.h>

/*
  GSM Send Sketch for Arduino
 
  Initializes GSM Module and sends an SMS to recipient
 
  The circuit:
  *Arduino pin 0 (RX) - GSM Module (TX)
  *Arduino pin 1 (TX) - GSM Module (RX)
 
  Created 2010
  by Meann Zabanal
  Modified
  by John for GSM Shield testing
*/

SoftwareSerial RFID(10,11);
char Rx_data[50];
unsigned char Rx_index = 0;
int i = 0;
char msg[160];
int sig;
char d;
char num[13];
char mes[150];

void setup() {
  Serial.begin(38400);
  Serial1.begin(9600);
  RFID.begin(9600);
 
 
}

void loop() {
  while (RFID.available()){
    char c=RFID.read();
    Serial1.println(c);
    delay(5);
    while (Serial1.available()<1){
      d=Serial1.read();
      if (d=='a'){String.toCharArray(num, 11);}
     
       
    }
  }
}
void send_msg(char *number, char *msg)
{
  char at_cmgs_cmd[30] = {'\0'};
  char msg1[160] = {'\0'};
  char ctl_z = 0x1A;

  sprintf(msg1, "%s%c", msg, ctl_z);
  sprintf(at_cmgs_cmd, "AT+CMGS=\"%s\"\r\n",number);
 
  sendGSM(at_cmgs_cmd);
  delay(100);
  delay(100);
  delay(100);
  sendGSM(msg1);
  delay(100);
}

void sendGSM(char *string){
  Serial.write(string);
  delay(90);
}

void clearString(char *strArray) {
  int j;
  for (j = 100; j > 0; j--)
    strArray[j] = 0x00;
}

void send_cmd(char *at_cmd, char clr){
  char *stat = '\0';
  while(!stat){
    sendGSM(at_cmd);
    delay(90);
    readSerialString(Rx_data);
   
    stat = strstr(Rx_data, "OK");
  }
  if (clr){
    clearString(Rx_data);
    delay(200);
    stat = '\0';
  }
}

void initGSM(){
 
  send_cmd("AT\r\n",1);
//  send_cmd("ATE0\r\n",1); // Turn off automatic echo of the GSM Module

  send_cmd("AT+CMGF=1\r\n",1); // Set message format to text mode
  //Sucess
 
  Serial.println("Success");

  delay(1000);
  delay(1000);
  delay(1000);
}

void readSerialString (char *strArray) {
 
  if(!Serial.available()) {
    return;
  }
 
  while(Serial.available()) {
    strArray[i] = Serial.read();
    i++;
  }
}

here's my error
Code:
final4.ino: In function 'void loop()':
final4:43: error: expected unqualified-id before '.' token
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49365
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
      if (d=='a'){String.toCharArray(num, 11);}
You don't have an instance of the String class called String. What are you trying to do here?
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4258
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
String.toCharArray(num, 11);
What string variable are you taking 11 bytes from ?

Oh, and what do you expect to get from
Code:
    while (Serial1.available()<1)
    {
      d=Serial1.read();
      if (d=='a')
      {
While Serial1 has zero bytes available read from it and test which character was received.  Will that work I wonder ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pages: [1]   Go Up
Jump to: