i have one doubt, how to send array value via gsm.
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.
I suggest you consider a different course/hobby.
Now your keyboard caps-lock has failed again. You really should go get a new keyboard - "screaming" on forums isn't the best way to get help...
How to send an integer? If you have a channel that doesn't support a binary transfer, then you need to encode the integer. This forum can't handle binary data but I can still send the integer 12345 to you. I just follow the normal encoding conventions on web forums and send it as the ASCII characters '1', '2', '3', '4', '5' after each other. Note that the language have ways of converting between ASCII digits and integer numbers on both directions. And it's also quite simple to "manually" perform the conversion using simple C code. 4103 is 4*1000 + 1*100 + 0*10 + 3*1. Or in the other direction: 4103/10000 = 0. 4103 - 0*10000 = 4103 4103/1000 = 4 4103 - 4*1000 = 103 103/100 = 1 103 - 1*100 = 3 3/10 = 0 3 - 0*10 = 3 3/1 = 3 3 - 3*1 = 0 Ignore the initial zero and the above got you 4, 1, 0, 3 which forms the decimal number 4103.
Your delay really is quite interesting - programming is the hobby of how to create complex functionality out of simpler primitives. All the way down to the language primitives of the compiler/assembler.
Doing:
delay(1000);delay(1000);delay(1000);delay(1000);
seems pretty silly when it's much easier to do:
delay(4000);
Next thing - it's way better to try to create a delay primitive that has some recognizeable physical property and then reuse it for longer delays. With some physical unit, it's way easier for a reader to understand how long the delay is expected to be.
If you have a function delay_one_ms() then you can implement:
void delay_milliseconds(unsigned ms) { while (ms) { --ms; delay_one_ms(); } } void delay_seconds(unsigned s) { while (s) { --s; delay_milliseconds(1000); } } void delay_hours(unsigned h) { while (h) { --h; delay_seconds(3600); } } void delay_days(unsigned d) { while (d) { --d; delay_hours(24); } }
Suddenly, you can with a single call delay_days(65535u) on a 16-bit processor create a delay of more than 179 years - longer than the longest human life. So why have a huge number of delay() calls after each other?
Note of course that a busy-loop delay that just counts clock cycles will give too long delays in more complex designs where the processor may allocate clock cycles to other things - like interrupt processing. That's why it's best to only create very short "at least" delays using busy-loop delays and make use of timers or other hardware to create longer delays with good precision.
I think you need to figure out what you want. You want to learn how to program? Then you can't give up and demand solutions from other people whenever you get stuck. You have to be willing to invest whatever time it takes to learn. As you learn, you'll notice that what you originally thought of as hard is actually quite simple. Just as it's extremely hard to implement walking robots but we humans manages quite well after a bit of training. There is no shortcut to avoid the need for training - you really do need to invest own time!
Thanks. one more favour, it is possible to send message to multiple contacts via GSM sim 900A module. If so send me reference code. please
That, surely, would be answered in the documentation for the SIM900A?
Have you studied the documentation for the SIM900A? Or contacted SIMCOM or your local supplier?
simcomm2m.com/.../
I tried but i am not getting any useful information there. so please guide me.
So why not just solving your problem by sending multiple SMS one at a time after each other? Would that be a too simple solution?
Hi, initially i am using AT89s52, but my coding size beyond 8kb. so i purchased AT89s8253. As per the datasheet its having 12kb, still my keil compiler version 4 showing (LIMIT 0800 BYTES. Now what i shall do.
Consider reading this page: http://www.keil.com/demo/limits.asp
Then consider if you have bought a commercial license or if you are running an evaluation version of the compiler limited according to the above information.