0

I want to pass the preprocessor values(AT commands) to the Serial.println function. Im trying TCP connection using arduino-SIM900A. I've declared all AT commands to each preprocessor variables like below

#define A "AT\r"
#define B "AT+CPIN?\"
...

I've assigned all preprocessor variables in char array and pass it into Serial.print using for loop.

char varAT[12]={'A','B'....};
for(int i=0;i<=12;i++)
{
Serial.print(varAT[i]);
}

Its not printing AT, instead it print preprocessor variable name A. I searched the google how to convert char value to variable, in C there is a function called "eval". Using eval we can acheive, but it wont work in arduino lang. How to solve this?

Thanks.

asked Jun 12, 2015 at 1:58

1 Answer 1

0

Ok, first, char varAT[12] indicates an array of 12 characters.

Second, quotes indicate literals - 'A' means, literally, the character 'A'. Variables and constants are without quotes (same way you use i).

I think you mean:

char *varAT[12]={A,B....};

Also, your constant B is invalid - I think you meant for it to end in \r", not \".

answered Jun 12, 2015 at 2:14
1
  • Thanks AMADANON. Its working. but i used char pointer char*. Once again thank you. Commented Jun 12, 2015 at 2:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.