Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Sumit Grover
Published © LGPL

SMS based notice board display

For display of the emergency message specially in College, hostel or hospital using SMS or wireless technique.

IntermediateFull instructions provided1,714
SMS based notice board display

Things used in this project

Hardware components

gsm modem
×1
P89V51RD2 IC
×1
40 PIN IC BASE
×1
GENERAL PURPOSE PCB
×1
TRANSFORMER 12-0-12
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×4
Capacitor 1000 µF
Capacitor 1000 µF
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
Capacitor 10 µF
Capacitor 10 µF
×1
CAPACITOR 33PF
×2
CRYSTAL 11.0592MHZ
×1
RESISTANCE 10KHZ
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

circuit

Code

code

C/C++
#include<reg51.h>	   	 
#include<intrins.h>	  

sbit buz=P1^7;

sbit SCL=P3^5;
sbit SDA=P3^4;	   

sbit rs=P3^2;
sbit en=P3^3;

sbit s1=P1^0;
sbit s2=P1^1;
sbit s3=P1^2;
sbit s4=P1^3;
sbit s5=P1^4;
sbit s6=P1^5;

sbit s7=P1^6;

void delay(unsigned int w)
{
unsigned int q;
for(q=0;q<w;q++);
}
	 
void cd(unsigned char c)
{
P2=c;
rs=0;
en=1;
delay(400);
en=0;
}

void dd(unsigned char c)
{
P2=c;
rs=1;
en=1;
delay(400);
en=0;
}

void lcd(unsigned char *h)
{
while(*h!=0)
{
dd(*h);
h++;
}
}

void init()
{
cd(0X38);
cd(0X01);
cd(0X06);
cd(0X0C);
}

void start()
{
   SDA = 1 ;	   _nop_() , _nop_() , _nop_() ;
   SCL = 1 ;	   _nop_() , _nop_() , _nop_() ;
   SDA = 0 ; 	   _nop_() , _nop_() , _nop_() ;
   SCL = 0 ;	   _nop_() , _nop_() , _nop_() ;
}

void stop()
{
   SDA = 0 ;	 _nop_() , _nop_() , _nop_() ;
   SCL = 1 ;	 _nop_() , _nop_() , _nop_() ;
   SDA = 1 ;	 _nop_() , _nop_() , _nop_() ;
   SCL = 0 ;	 _nop_() , _nop_() , _nop_() ;
}

void clock()
{
   SCL = 1 ;	 _nop_() ; _nop_() ; _nop_() ;
   SCL = 0 ;	 _nop_() ; _nop_() ; _nop_() ;
}

void nack()
{
    SDA = 1 ;	  clock() ;
} 


void waitack()
{
    SDA = 1 ;	  clock() ;
}

void opdat(unsigned char dat)
{
   unsigned char i ;
   for ( i = 0 ; i < 8 ; i++ )
   {
      if ( ( dat >> ( 7 - i ) ) & 0x01 ) 	SDA = 1 ; 
      else	 			SDA = 0 ;
      clock() ;
   }
}

void i2c_write(unsigned char dat,unsigned char addr)
{                   	
	start();		 //dummy write start 	
	opdat(0xa0);	//send dev addr
	waitack();
	opdat(addr);
	waitack();
	opdat(dat);		//write data
	waitack();
	stop();
}	
		
unsigned char getdat()
{
   unsigned char i , dat;
   SDA = 1;	   _nop_() , _nop_() , _nop_();
 for ( i = 0 ; i < 8 ; i++ ) 
   {
	  dat = ( ( ( dat << 1 ) & 0xfe ) | SDA );
	  clock();
   }
   return dat;
}

unsigned char i2c_read(unsigned char addr)
{ 
 unsigned char rdata;
start();		//dummy write start
opdat(0xa0);	//send dev addr
waitack();
opdat(addr);
waitack();
	start();				//start read
       opdat(0xa1);   //give device adddr or with for read 
        waitack();	//operation coz lsb gives r|w
        rdata = getdat();
        nack() ;
        stop() ;
        return(rdata);
}

void tx(unsigned char num)
{ 
SBUF = num;
while(TI == 0);
TI = 0;
}

void tx_str(unsigned char *y)
{
while(*y!='\0')
	{
		tx(*y);
		y++;
	}
}

void main()
{

unsigned int e;
unsigned char m=0,g,r,q=0,w,t,arr[85],arr2[15];

buz=0;

SCON=0x50;
TMOD=0x20;
TH1=0xfd;
TR1=1;											  
init();

cd(0x80);
lcd(" GSM  BASED  NOTICE ");
cd(0xc0);
lcd("   BOARD  DISPLAY   ");
cd(0x94);
lcd("  PLEASE WAIT FOR   "); 
cd(0xd4);
lcd(" MODEM TO BE ACTIVE ");

delay(60000); 					 
delay(60000); 	
delay(60000); 					 
delay(60000); 	
delay(60000); 					 
delay(60000); 	
delay(60000); 			
						
qwe:
g=i2c_read(0);
delay(100);
	
q=0;  	
tx_str("AT");
tx(0x0d);			  
delay(60000);	
tx_str("AT+CMGF=1");
tx(0x0d);	  
delay(60000);
delay(60000); 
delay(60000);
buz=0;
if(g==0)
goto mnb;

cd(0x94);
lcd("   PLEASE    SEND   "); 
cd(0xd4);
lcd("  IMPORTANT NOTICE  ");
 
while(1)
{
nbv: 
if(g==0)
{
if(s1==0)
{
cd(0xdd+q);
dd('*');
while(s1==0);
delay(10000);
arr[q]='1';
q=q+1;
}
else if(s2==0)
{		
cd(0xdd+q);
dd('*');
while(s2==0);
delay(10000);  
arr[q]='2';
q=q+1;
}		
else if(s3==0)
{		
cd(0xdd+q);
dd('*');
while(s3==0);
delay(10000);
arr[q]='3';
q=q+1;
}					  
else if(s4==0)
{		
cd(0xdd+q);
dd('*');
while(s4==0);
delay(10000);
arr[q]='4';
q=q+1;
}		
else if(s5==0)
{		
cd(0xdd+q);
dd('*');
while(s5==0);
delay(10000);
arr[q]='5';
q=q+1;
}		
else if(s6==0)
{		
cd(0xdd+q);
dd('*');
while(s6==0);
delay(10000);
arr[q]='6';
q=q+1;
}	 	
else if(s7==0)
{
if(q==5)
{	
for(w=0;w<10;w++)
{
arr2[w]=i2c_read(82+w);
delay(100);
}
if(arr[0]=='1' && arr[1]=='2' && arr[2]=='3' && arr[3]=='4' && arr[4]=='5')
{
t=i2c_read(100);
delay(100);
if(t==0)
{			  
cd(0xd4);
lcd("MESSAGE ALREADY SENT");
delay(60000);
delay(60000);
delay(60000);
delay(60000); 	
goto qwe;
}
i2c_write(0,100);
delay(1200);
tx_str("AT+CMGS=");
tx('"');
tx('0');
for(w=0;w<10;w++)
{
tx(arr2[w]);
}
tx('"');
tx(0x0d);
delay(20000);
tx_str("TEACHER 1 HAS SEEN");
tx(0x1a); 						
cd(0xd4);
lcd(" MESSAGE DELIEVERED ");	
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}			
else if(arr[0]=='2' && arr[1]=='3' && arr[2]=='4' && arr[3]=='5' && arr[4]=='6')
{			 
t=i2c_read(101);
delay(100);
if(t==0)
{			  
cd(0xd4);
lcd("MESSAGE ALREADY SENT");	  
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}
i2c_write(0,101);
delay(1200);
tx_str("AT+CMGS=");
tx('"');
tx('0');
for(w=0;w<10;w++)
{
tx(arr2[w]);
}
tx('"');
tx(0x0d);
delay(20000);
tx_str("TEACHER 2 HAS SEEN");
tx(0x1a); 						
cd(0xd4);
lcd(" MESSAGE DELIEVERED ");	
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}			
else if(arr[0]=='6' && arr[1]=='5' && arr[2]=='4' && arr[3]=='3' && arr[4]=='2')
{			   
t=i2c_read(102);
delay(100);
if(t==0)
{			  
cd(0xd4);
lcd("MESSAGE ALREADY SENT");	  
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}
i2c_write(0,102);
delay(1200);
tx_str("AT+CMGS=");
tx('"');
tx('0');
for(w=0;w<10;w++)
{
tx(arr2[w]);
}
tx('"');
tx(0x0d);
delay(20000);
tx_str("TEACHER 3 HAS SEEN");
tx(0x1a); 						
cd(0xd4);
lcd(" MESSAGE DELIEVERED ");	
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}				 			
else if(arr[0]=='5' && arr[1]=='4' && arr[2]=='3' && arr[3]=='2' && arr[4]=='1')
{			   
t=i2c_read(103);
delay(100);
if(t==0)
{			  
cd(0xd4);
lcd("MESSAGE ALREADY SENT");	  
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}
i2c_write(0,103);
delay(1200);
tx_str("AT+CMGS=");
tx('"');
tx('0');
for(w=0;w<10;w++)
{
tx(arr2[w]);
}
tx('"');
tx(0x0d);
delay(20000);
tx_str("TEACHER 4 HAS SEEN");
tx(0x1a); 						
cd(0xd4);
lcd(" MESSAGE DELIEVERED ");	
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}				
else if(arr[0]=='3' && arr[1]=='4' && arr[2]=='5' && arr[3]=='6' && arr[4]=='1')
{			   
t=i2c_read(104);
delay(100);
if(t==0)
{			  
cd(0xd4);
lcd("MESSAGE ALREADY SENT");	  
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}
i2c_write(0,104);
delay(1200);
tx_str("AT+CMGS=");
tx('"');
tx('0');
for(w=0;w<10;w++)
{
tx(arr2[w]);
}
tx('"');
tx(0x0d);
delay(20000);
tx_str("TEACHER 5 HAS SEEN");
tx(0x1a); 	  
cd(0xd4);
lcd(" MESSAGE DELIEVERED ");	
delay(60000);
delay(60000);
delay(60000);
delay(60000); 
goto qwe;
}	
else
{
cd(0xd4);
lcd("  WRONG   PASSWORD  ");	
delay(60000); 					
delay(60000); 
}
}
else
{
cd(0xd4);
lcd("  WRONG   PASSWORD  ");	
delay(60000); 					
delay(60000); 
}
q=0;
goto mnb;	
}
if(q==1)
{
cd(0xd4);
lcd("PASSWORD");
}
}
if(RI==1)
{
w=SBUF;
RI=0;
if(w=='+')
{
e=0;
while(RI==0)
{
e=e+1;
if(e>30000)
goto qwe;
}
RI=0;
q=SBUF; 
e=0;
while(RI==0)
{
e=e+1;
if(e>30000)
goto qwe;
}
RI=0;
q=SBUF; 
e=0;
while(RI==0)
{
e=e+1;
if(e>30000)
goto qwe;
}
RI=0;
q=SBUF; 
if(q=='T')
{			
delay(30000);
tx_str("AT+CMGR=1");
tx(0x0d);
delay(60000); 
zxc:	   
e=0;
while(RI==0)
{
e=e+1;
if(e>30000)
{
goto qwe;
}
}
RI=0;
r=SBUF; 
if(r!=':')
goto zxc;		
r=0;
xcv:	   
e=0;
while(RI==0)
{
e=e+1;
if(e>30000)
{
goto qwe;
}
}
RI=0;
r=SBUF; 
if(r!='+')
goto xcv;		
r=0;
asd:   
e=0;
while(RI==0)
{
e=e+1;
if(e>30000)
{
goto qwe;
}
}
RI=0;
arr2[r]=SBUF;
r=r+1;
if(SBUF!='"')
goto asd;
r=0;
wer:	   
e=0;
while(RI==0)
{
e=e+1;
if(e>30000)
{
goto qwe;
}
}
RI=0;
r=SBUF; 
if(r!='*')	
goto wer;	
r=0;
ert:   
e=0;
while(RI==0)
{
e=e+1;
if(e>30000)
{	
q=0;
goto qwe;
}
}
RI=0;
arr[r]=SBUF;
r=r+1;
if(SBUF!='#')
goto ert;		
if(r>9)
{
if(arr[0]=='M' && arr[1]=='E' && arr[2]=='S' && arr[3]=='S' && arr[4]=='A' && arr[5]=='G' && arr[6]=='E' && arr[7]==' ')
{ 
buz=1; 			  
i2c_write(0,0);
delay(1200);	  
i2c_write(1,100);
delay(1200);	  
i2c_write(1,101);
delay(1200);	  
i2c_write(1,102);
delay(1200);	  
i2c_write(1,103);
delay(1200);	  
i2c_write(1,104);
delay(1200);	  
i2c_write((r-9),1);
delay(1200);
for(t=2;t<12;t++)
{
i2c_write(arr2[t],(t+80));
delay(1200);
}				
for(t=2;t<(r-7);t++)
{
i2c_write(arr[(6+t)],t);
delay(1200);
if(r>80)
goto qwe;
}	
q=0;
goto qwe;
}
}
}
q=0;
goto qwe;
}
} 
if(m==1)
{
mnb:			   
cd(0x80);
lcd("                    ");
cd(0xc0);
lcd("                    ");
cd(0x94);
lcd("                    "); 
cd(0xd4);
lcd("                    ");
q=i2c_read(1);
delay(100);
if(q<=20)
{
cd(0x80);
for(w=0;w<q;w++)
{
dd(i2c_read(w+2));
}
}		 
else if(q>20 && q<=40)
{
cd(0x80);
for(w=0;w<20;w++)
{
dd(i2c_read(w+2));
}			
cd(0xc0);
for(w=20;w<q;w++)
{
dd(i2c_read(w+2));
}
}		 
else if(q>40 && q<=60)
{
cd(0x80);
for(w=0;w<20;w++)
{
dd(i2c_read(w+2));
}			
cd(0xc0);
for(w=20;w<40;w++)
{
dd(i2c_read(w+2));
}			 
cd(0x94);
for(w=40;w<q;w++)
{
dd(i2c_read(w+2));
}			
}		 
else if(q>60 && q<=80)
{
cd(0x80);
for(w=0;w<20;w++)
{
dd(i2c_read(w+2));
}			
cd(0xc0);
for(w=20;w<40;w++)
{
dd(i2c_read(w+2));
}			 
cd(0x94);
for(w=40;w<60;w++)
{
dd(i2c_read(w+2));
}			 
cd(0xd4);
for(w=60;w<q;w++)
{
dd(i2c_read(w+2));
}			
}
delay(60000);
delay(60000);
q=0;
goto nbv;
}  
}
}

Credits

Sumit Grover

Sumit Grover

8 projects • 31 followers

Comments