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.

[SOLVED] Help for Simple alarm system needed!!!

Status
Not open for further replies.

E11022

Junior Member level 2
Junior Member level 2
Joined
Feb 28, 2010
Messages
21
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,474
Hi,

I need help for my project on alarm system for the programming part. Now, what i want to do is just as below :
input -sensor, switch
output = LED
PIC - 16F877 being used


if Sensor is on, Switch(Reset) Off, LED ON
if Sensor is on, Switch(Reset) ON, LED OFF


Below is the program i write, but no matter how i try/ edit the program, it is not working. Can anyone provide me a program for it or tell me wat wrong with my programming!!please help me!!!
Thanks


#include <pic.h>

__CONFIG(0x3F32);

#define sensor RA0
#define sw RA1
#define buzzer RC4

void main (void)

{

ADCON1 = 0x06;

TRISA=0b11111111;
TRISC=0b00000000;

sensor=0;
sw=0;
buzzer=0;

while(1)
{

if ((sensor == 1) && (sw =0))
{ buzzer=1;}
else if ((sensor == 1) && (sw =1))
{ buzzer=0;}
else {buzzer =0;}
break;

}
}
 

remove the break and try. i think that may be the problem
 

hi there,

if ((sensor == 1) && (sw =0))
{ buzzer=1;}
else if ((sensor == 1) && (sw =1))

As I understood you`re trying to check sensor AND sw, ok? If so, you must use "==" instead "=", ok?
In other words (sw == 0).

just trying to clarify better. When you use = you are assigning a value to variable, and when you use == you`re testing a condition.

best regards
 
  • Like
Reactions: E11022

    E11022

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top