E11022
Junior Member level 2
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;
}
}
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;
}
}