i have one doubt, how to send array value via gsm.
A character at a time. Duh!
no , i am generating password that password should send through gsm.
Yes. Send one character at a time.
If you think that is your only doubt, you have plenty to learn.
You aren't wery clear here.
Is your password intended to log in to the network, like a PAP or CHAP secret?
Or do you want to send the password somewhere - like in an SMS?
Anyway - the communication with the module happens character by character. Sometimes with the characters grouped into text lines like when you send AT commands.
THANKS FOR YOUR REPLY. THE PROBLEM IS THAT WHENEVER I AM PASSING STRING IT ACCEPT BUT WHEN I AM PASSING INT IT'S NOT TAKING.
I TRIED BUT THE VALUE IS NOT SEND VIA GSM
1) Repair your keyboard - the caps-lock key seems to be stuck.
2) Not sure what you mean by passing int. An int can store a character - so if sent as a parameter to a function that expects a single character it should work. If sent to a function that expects a string you'll get a compilation error - unless you typecast the int to a char pointer. But that only works if the int is really storing the address of an array of characters.
3) Learn how to write descriptive text. "I TRIED BUT THE VALUE IS NOT SEND VIA GSM" doesn't really tell much. If I say "the car doesn't work", it's impossible for someone to know what is wrong with the car...
sorry for that. I am generating random password. I want to send the password to gsm. now thing is that when i am sending text example uart_send("password received")i am getting the text, but i am not getting password. i do no what is the problem. i hope u understand my doubt.
That is still no more informative than saying, "my car doesn't work" - and expecting anyone to be able to diagnose the problem with no further information!
Clearly, you are doing something wrong - but we cannot see your code, so we cannot tell what that might be!
The fact that you can send some things shows that your basic setup must be working; so you need to investigate and think about how it differs in the password case...
#include <REGX52.H> #include <stdlib.h> #include <stdio.h> //#include <time.h>
char password();
void lcd_init(); void lcd_cmd(unsigned char x); void lcd_data(unsigned char y); void lcd_name(char *ptr);
void delay (int y);
void clockwise(); void anticlockwise(); void off();
void uart_msg(unsigned char *c); void uart_msg1(unsigned int *n); unsigned char uart_rx(); void uart_tx(unsigned char x); void uart_init(); void gsm();
unsigned int ori, bis; void tst_rand (void); ///random generation void lcd_data_int(int i);
sbit rs = P3^4; sbit rw = P3^3; sbit en = P3^2;
sbit IN1 = P3^5; // motor drive sbit IN2 = P3^6; sbit EN1 = P3^7;
//sbit rx = P3^0; //sbit tx = P3^1;
sbit sw = P1^6; sbit v = P1^7; //vibration sensor
//keypad a sbit J =P1^0; sbit O =P1^1; sbit S =P1^2;
sbit A =P1^3; sbit a =P1^4; sbit C =P1^5; sbit D =P1^6;
char temp[5]; char rev[5]; int z,x=0;
void main() {
sw=1; v=1; EN1=1; lcd_init(); uart_init(); lcd_cmd(0x80); lcd_name("ADVANCE SECURITY"); delay(1000);delay(1000); delay(1000);delay(1000); delay(1000);delay(1000); delay(1000);delay(1000); delay(1000);delay(1000); lcd_cmd(0xc0); lcd_name("SYSTEM IN ATM"); delay(1000);delay(100); delay(1000);delay(1000); delay(1000);delay(1000); delay(1000);delay(1000); delay(1000);delay(1000); lcd_cmd(0x01); lcd_cmd(0x80); lcd_name("welcome..."); delay(65000); //off();
while(1) { if(v==0) { anticlockwise(); delay(6500); lcd_cmd(0x01); lcd_cmd(0x80); lcd_name("SHUTTER CLOSED"); delay(6500);delay(6500);delay(6500);delay(6500);delay(6500);delay(6500); delay(6500);delay(6500); delay(6500); delay(100); delay(1000);delay(1000);delay(1000);delay(1000);delay(1000);delay(1000); off(); gsm(); delay(6500);delay(6500);delay(6500);delay(6500);delay(6500);delay(6500); delay(6500);delay(6500);delay(6500);delay(6500);delay(6500);delay(6500); delay(1000);delay(1000);delay(1000);delay(1000);delay(1000);delay(1000); delay(1000);delay(1000);delay(1000);delay(1000);delay(1000);delay(1000); delay(1000);delay(1000);delay(1000);delay(1000);delay(1000);delay(1000); delay(1000);delay(1000);delay(1000);delay(1000);delay(1000);delay(1000); delay(1000);delay(1000);delay(1000);delay(1000);delay(1000);delay(1000); tst_rand(); ori=rand(); lcd_cmd(0x01); lcd_cmd(0x80); lcd_name("ENTER PWD:"); for(z=0;z<4;z++) { temp[z]=password(); // lcd_data(i+0x30); lcd_cmd(0xc0+z); lcd_name("*"); } if((rev[0]==temp[0])&& (rev[1]==temp[1]) && (rev[2]==temp[2]) && (rev[3]==temp[3]))
{ lcd_cmd(0x01); lcd_cmd(0x80); lcd_name("PASSWORD MATCH"); clockwise(); delay(65000);delay(1000); lcd_cmd(0x01); lcd_name(0x80); lcd_name("DOOR OPEN"); delay(1000); delay(65000);delay(65000);delay(65000);delay(65000);delay(65000); delay(1000); off(); } else { lcd_cmd(0x01); lcd_cmd(0x80); lcd_name("WRONG PASSWORD"); off(); delay(1000);delay(6500); delay(1000);delay(1000); delay(1000);delay(6500);
} } } }
void lcd_init() { lcd_cmd(0x0E); lcd_cmd(0x38); lcd_cmd(0x80); }
void lcd_cmd(unsigned char x) { rs=0; rw=0; P2=x; en=1; delay(9600); en=0; }
void lcd_data(unsigned char y) { rs=1; rw=0; P2=y; en=1; delay(9600); en=0; }
void lcd_name(char *ptr) { while(*ptr!='\0') lcd_data(*ptr++); }
void delay(int y) { while(y--); }
void anticlockwise() { IN1=1; IN2=0; }
void clockwise() { IN1=0; IN2=1; }
void off() { v=1; sw=1; //lcd_cmd(0x01); //lcd_cmd(0x80); IN1=0; IN2=0; }
void gsm() { uart_msg("AT"); uart_tx(0X0d); uart_tx(0X0a); delay(65000);delay(65000);delay(65000); uart_msg("AT+CMGF=1"); uart_tx(0X0d); uart_tx(0X0a); delay(65000);delay(65000);delay(65000); uart_msg("AT+CMGS=\"\""); delay(65000);delay(65000);delay(65000); uart_tx(0X0d); uart_tx(0X0a); delay(65000);delay(65000);delay(65000); uart_msg("ATM ROBBERY"); uart_tx(0X0d); uart_tx(0X1a); uart_msg(&temp[0]);// here i am facing pblm that i am not getting the value delay(200); delay(200);delay(200); delay(200); }
void uart_init() { SCON=0X50; TMOD=0x20; TH1=0xFD; TL1=0x00; TR1=1; }
void uart_tx(char x) { SBUF=x; while(TI==0) delay(1); TI=0; }
unsigned char uart_rx() { unsigned char z; while(RI==0); z = SBUF; RI=0; return(z); }
void uart_msg(unsigned char *c) { while(*c != '\0' ) uart_tx( *c++); } void uart_msg1(unsigned int *n) { while(*n != '\0' ) uart_tx( *n++); }
void lcd_data_int(int i) // to send three digit number {
//double int n=0; unsigned long int m,o,p,q;
m= i/1000; o= (i%1000)/100; p= ((i%100)/10); q= i%10; rev[0]=m; rev[1]=o; rev[2]=p; rev[3]=q; lcd_data(m+0x30); lcd_data(o+0x30); lcd_data(p+0x30); lcd_data(q+0x30); delay(65000); }
void tst_rand (void)
{ unsigned long int i; i= rand(); i=i/10; lcd_cmd(0x80); lcd_cmd(0x01); lcd_name("GENERATED PWD: "); delay(250); lcd_cmd(0xc0); lcd_data_int(i); }
char password() { while(1) { J=O=S=1; A=0;a=1;C=1;D=1;
if((A==0)&&(J==0)){while((A==0)&&(J==0))delay(10);return 1; J=1;} if((A==0)&&(O==0)){while((A==0)&&(O==0))delay(10);return 2; O=1;} if((A==0)&&(S==0)){while((A==0)&&(S==0))delay(10);return 3; S=1;}
J=O=S=1; A=1;a=0;C=1;D=1;
if((a==0)&&(J==0)){while((a==0)&&(J==0))delay(10);return 4; J=1;} if((a==0)&&(O==0)){while((a==0)&&(O==0))delay(10);return 5; O=1;} if((a==0)&&(S==0)){while((a==0)&&(S==0))delay(10);return 6; S=1;}
J=O=S=1; A=1;a=1;C=0;D=1;
if((C==0)&&(J==0)){while((C==0)&&(J==0))delay(10);return 7; J=1;} if((C==0)&&(O==0)){while((C==0)&&(O==0))delay(10);return 8; O=1;} if((C==0)&&(S==0)){while((C==0)&&(S==0))delay(10);return 9; S=1;}
J=O=S=1; A=1;a=1;C=1;D=0; if((D==0)&&(J==0)){while((D==0)&&(J==0))delay(10);return 0;} if((D==0)&&(O==0)){while((D==0)&&(O==0))delay(10);return 0;} if((D==0)&&(S==0)){while((D==0)&&(S==0))delay(10);return 0;}
} }
How many seconds did you spend reading the instructions of how to post source code?
That's one cool way of making extended delays. Not!
i am new to programming, i am learning.
I AM NOT UNDERSTAND WHAT YOU ARE TRYING TO SAY.
WILL U SEND ME REFERENCE CODE FOR GSM FOR IC 89S52. I AM NOT UNDERSTAND THE PROBLEM IN MY CODING. WILL U HELP ME WHERE I AM STRUCK. LET ME CLEAR ONE THING IT IS POSSIBLE TO SEND ANY INTERGER VALUE THROUGH GSM. IF SO SEND ME THE SYNTAX PLS.