Smart Power management system in any management system
Smart Power management system in any management system
Protocols: UART, RTC, LCD
Brief: We are doing this project to controlling lighting, fans etc by using mobile Bluetooth pairing to arm device HC-05 Bluetooth here working automatic particular time it will check the status of lights etc then that will send to mobile phone will you feel turn off or on that operation will be done by requested small commands from mobile.
Hardware Used: lpc2129 development board (ARM7), Bluetooth module HC-05, relay, Ac bulb.
Software Used: Keil µVision 4, Flash Magic
code for the above project
//same as 1st prg but simplyfing code we are using funtions
#include<lpc21xx.h>
#include<string.h>
void uart_tx_string(char *str);
void delay(int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<3000;j++)
{
}
}
}
#include<lpc21xx.h>
#include<string.h>
void uart_tx_string(char *str);
void delay(int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<3000;j++)
{
}
}
}
void init_rtc()
{
CCR=(1<<0); // enable
PREINT=456; // crystel oscillator giving 15Mhz, but rtc will work at 32.768khz to scle this we are using formula and geting this number
PREFRAC=25024;
HOUR=12;
ALHOUR=12;
ALMIN=12;
MIN=11;
SEC=0;
{
CCR=(1<<0); // enable
PREINT=456; // crystel oscillator giving 15Mhz, but rtc will work at 32.768khz to scle this we are using formula and geting this number
PREFRAC=25024;
HOUR=12;
ALHOUR=12;
ALMIN=12;
MIN=11;
SEC=0;
}
void uart_int(void)
{
PINSEL0 |= (1<<0)|(1<<2); // configuring the UART funtion
PINSEL0 &= ~((1<<1)|(1<<3));
U0LCR = (1<<0)|(1<<1)|(1<<7); // configuring line control register(LCR),DLATCH
U0DLM = 0; // Loding value DLM and DLL
U0DLL = 97;
U0LCR = (1<<0)|(1<<1); // disable the DLATCH register
}
char uart_rx (void)
{
while(!(U0LSR & (1<<0)));
return (U0RBR);
}
void uart_tx(char c)
{
while(!(U0LSR & (1<<5)));
U0THR = c;
}
{
while(!(U0LSR & (1<<5)));
U0THR = c;
}
void uart_tx_string(char *str)
{
while(*str)
{
uart_tx(*str);
str++;
}
}
int main()
{
int i,b=0;
char *password = "check";
char recvpass[5]={0};
uart_int();
IODIR1=(1<<25);
IODIR1=(0xff<<17);
init_rtc();
g:
while((ALHOUR==HOUR)&&(MIN==ALMIN))
{
if((1<<18)&&IOPIN1)
{
uart_tx_string("new loop\n");
}
}
uart_tx_string("input running\n");
{
while(*str)
{
uart_tx(*str);
str++;
}
}
int main()
{
int i,b=0;
char *password = "check";
char recvpass[5]={0};
uart_int();
IODIR1=(1<<25);
IODIR1=(0xff<<17);
init_rtc();
g:
while((ALHOUR==HOUR)&&(MIN==ALMIN))
{
if((1<<18)&&IOPIN1)
{
uart_tx_string("new loop\n");
}
}
uart_tx_string("input running\n");
if(IOPIN1&(1<<25))
{
IOSET1=(1<<17);
uart_tx_string("on \n");
}
else
{
IOCLR1=(1<<17);
uart_tx_string("off \n");
}
for(i=0;i<5;i++)
{
recvpass[i]=uart_rx();
uart_tx(recvpass[i]);
}
if(strncmp(password,recvpass,5)==0)
{
uart_tx_string("please wait satus checking\n");
if(IOPIN1&(1<<17))
uart_tx_string("frist light on\n");
}
else
{
uart_tx_string("string not match\n");
}
{
IOSET1=(1<<17);
uart_tx_string("on \n");
}
else
{
IOCLR1=(1<<17);
uart_tx_string("off \n");
}
for(i=0;i<5;i++)
{
recvpass[i]=uart_rx();
uart_tx(recvpass[i]);
}
if(strncmp(password,recvpass,5)==0)
{
uart_tx_string("please wait satus checking\n");
if(IOPIN1&(1<<17))
uart_tx_string("frist light on\n");
}
else
{
uart_tx_string("string not match\n");
}
if((ALHOUR==HOUR)&&(MIN==ALMIN)&&(IOPIN1&(1<<17)))
{
IOSET1=(1<<18);
}
else
{
IOCLR1=(1<<18);
}
{
IOSET1=(1<<18);
}
else
{
IOCLR1=(1<<18);
}
goto g;
}
}
Comments
Post a Comment