Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

hi unable to receive & turn on & off relay using pic16f876a plz help me

Status
Not open for further replies.

aviraje8

Newbie level 5
Joined
Nov 21, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
119

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
unsigned char sms_in[90];
bit flag;
unsigned int i=0;
void interrupt()
 {
  if (PIR1.RCIF==1)
  {
    if (UART1_Data_Ready())
   {
    sms_in[i] = UART1_Read();
 
    if(sms_in[i]=='K')
    {
   flag=1;
    }
    i++;
   }
 
  }
}
 
 
 
 
 
void main()
{
     INTCON.GIE = 1;
     INTCON.PEIE = 1;
     PIE1.RCIE=1;
 
     TRISC5_bit = 0;
     UART1_Init(9600);
     Delay_ms(500);
 
while(1)
{
 
if(flag==1)
     {
    char q=5;
    if(sms_in[q]=='O'&& sms_in[q+1]=='N'&& sms_in[q+2]=='1')
    {
     RC5_bit=1;
     UART1_Write(0X0D);
     UART1_Write(0X0A);
     flag=0;
      i=0;
    }
 
    else if(sms_in[q]=='O'&& sms_in[q+1]=='F'&& sms_in[q+2]=='F')
    {
     RC5_bit=0;
     UART1_Write(0X0D);
     UART1_Write(0X0A);
     flag=0;
      i=0;
    }
 
    }
   }
}

 
Last edited by a moderator:

Your code is Ok. I think its an Hardware Fault, Upload your circuit.
 

I hope you're using a buffer and not trying to toggle the relay directly with an MCU gpio.
Post you circuit and the data sheet of the relay...
 

hi i am using sim900
if i receive SMS ON the relay should be ON
if i receive SMS OFF the relay should be OFF Untitled.png
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top