Beruflich Dokumente
Kultur Dokumente
/ LCD connection
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit
sbit
sbit
sbit
sbit
sbit
LCD_RS_Direction
LCD_EN_Direction
LCD_D4_Direction
LCD_D5_Direction
LCD_D6_Direction
LCD_D7_Direction
at
at
at
at
at
at
TRISB2_bit;
TRISB3_bit;
TRISB4_bit;
TRISB5_bit;
TRISB6_bit;
TRISB7_bit;
0x02;
0;
= 0;
= 0;
TRISB = 0;
TRISD = 0;
TRISC = 0;
TRISA = 0X07;
UART1_Init(9615);
Move_Delay();
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, text4);
Lcd_Out(1, 1, text5);
do
{
read_value = ADC_Read(1);
PORTD = read_value;
if(read_value > THRESHOLD )
on
{
if(change == 0)
{
writeWarning();
n lcd and send sms to GSM
//gsm_SMS_Init();
//pic_Send_SMS();
//Read_SMS();
change = 1;
}
}
else
// safe
{
if(change == 1)
fe operation
{
writeNormal();
change = 0;
}
}
} while(1);
}
void writeWarning()
{
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,text1);
Lcd_Out(2, 1, text2);
Lcd_Out(3, 1, text3);
// clear Display
// Turn cursor off
}
void writeNormal()
{
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1, text4 );
Lcd_Out(1, 1, text5);
// clear Display
// Turn cursor off
// text to display
// display normal operation on lcd
}
void Move_Delay()
{
Delay_ms(500);
}
void Read_SMS(void)
{
pic_Send_SMS();
// send text
UART1_Write_Text("AT+CGMM= 1");
// GET supported frequency band
UART1_Write_Text("AT");
// send AT to the GSM
//Move_Delay();
// Delay
UART1_Write_Text("AT+CMGF=1 ");
// sms configuration /SET TEXT MODE
//Move_Delay();
UART1_Write_Text("AT+CNMA= 1");
//ACKNOWLEDGE NEW SMS
UART1_Write_Text("AT+CMGR= 1\n\r");
UART1_Write_Text("AT+CGMR= 1\n\r");
// request revision identification
//Move_Delay();
UART1_Write_Text("AT+CPMS= output");
// store from the ram (BM)
UART1_Write_Text("AT+CMGL= 1");
//list message
UART1_Write_Text("AT+CMGR= 1\n\r");
// Read message
//Move_Delay();
UART1_Write_Text("AT+CPMS= output");
// read from the ram (BM)
while (UART1_Data_Ready() == 0) ;
for(i=0;i<=65;i++)
{
output[i]=UART1_Read();
}
}
void pic_Send_SMS()
{
do
{
//gsm_SMS_Init();
//Read_SMS();
UART1_Write_Text("AT+CSMS=
UART1_Write_Text("AT+CGMI=
ion
UART1_Write_Text("AT+CMGS=
UART1_Write(0x0D);
Move_Delay();
UART1_Write_Text("AT+CMGW=
1");
1");
+0682006300");
//Write "AT+CMGS= 1"
// mean (Enter)
// Delay
1");
// WRITE message
UART1_Write_Text("AT+CMSS= 1");
//SEND MESSAGE
//UART1_Write_Text("AT+CMGS= ");
//Write "AT+CMGS="
UART1_Write(0x22);
UART1_Write_Text("AT = +255682006300"); // Phone Number SMS send to
UART1_Write(0x22);
UART1_Write(0x0D);
// mean (ENTER)
UART1_Write_Text("\n\r");
Move_Delay();
// Delay
UART1_Write_Text(output);
// Word to be sent
UART1_Write(26);
// send ctrl + Z
Move_Delay();
// Delay
}
while(1);
}