bashekmagroh
New Member
Hello …
This is the project that I want your help on it and I will show the schematic first :
**broken link removed**
when I connect the power to the circuit I have to press the switch first witch is coming from pin number ( 2- RA0 ) and the led from pin num ( 11 –RC0) will be on , and then it will wait 15 second then activate the sensor . when any detection happen to the sensor the buzzer and the Led will start to beep . in form of : beep – off - beep – off – beep – off – beep - off …… etc
And then to set this circuit I have to press 2 buttons :
_ first one the MCLR which is coming from pin num ( 1).
- The second one is I have to press the switch that is coming from pin num (2- RA0) .
- Then the process will redo again. Wait 15 second first then activate the sensor
What I want you to modify is the program inside the PIC . My request is : the beep from the buzzer I want to be only beep one time and for 4 seconds . in the original program it will beep – off - beep – off – beep – off – beep - off …… etc. and then I want to reactivate the circuit automatically witch mean I don’t want to press the 2 switches witch is coming from( pin number 1 and pin number 2). Also want the waiting of 15 seconds I want it to be 1 or 2 seconds .
This is the program that I want to be modified :
This is the project that I want your help on it and I will show the schematic first :
**broken link removed**
when I connect the power to the circuit I have to press the switch first witch is coming from pin number ( 2- RA0 ) and the led from pin num ( 11 –RC0) will be on , and then it will wait 15 second then activate the sensor . when any detection happen to the sensor the buzzer and the Led will start to beep . in form of : beep – off - beep – off – beep – off – beep - off …… etc
And then to set this circuit I have to press 2 buttons :
_ first one the MCLR which is coming from pin num ( 1).
- The second one is I have to press the switch that is coming from pin num (2- RA0) .
- Then the process will redo again. Wait 15 second first then activate the sensor
What I want you to modify is the program inside the PIC . My request is : the beep from the buzzer I want to be only beep one time and for 4 seconds . in the original program it will beep – off - beep – off – beep – off – beep - off …… etc. and then I want to reactivate the circuit automatically witch mean I don’t want to press the 2 switches witch is coming from( pin number 1 and pin number 2). Also want the waiting of 15 seconds I want it to be 1 or 2 seconds .
This is the program that I want to be modified :
HTML:
#include <pic.h>
// configuration
//==========================================================================
__CONFIG (0x3F32);
// define
//==========================================================================
#define alarm_set RA0
#define sensor RB2
#define led RC0
#define buzzer RC4
// main function
//==========================================================================
void main(void)
{
unsigned char status;
unsigned long temp1,temp2;
ADCON1 = 0x06; //Congifure Port A as digital I/O
TRISA = 0b11111111; //Configure Port A as Input
TRISB = 0b11111111; //Configure Port B as Input
TRISC = 0b00000000; //Configure Port C as Output
status=0;
led=0;
buzzer=0;
while(1) //Infinity Loop
{
//scan input
if((alarm_set==0)&&(status!=3)) //Alarm set
{
while(alarm_set==0) continue;
status=1;
temp1=0;
}
if((sensor==1)&&(status==2)) //Motion detected
status=3;
//processing output
switch(status)
{
//Permitted period mode (15 seconds)
case 1:
led=1;
temp1+=1;
if(temp1<10000) buzzer=1; //Sound 'Beep'
else if(temp1>1000000)
{
temp1=0;
status=2;
}
else buzzer=0;
break;
//Scanning mode
case 2:
temp2+=1;
if(temp2<2500) led=1; //LED blink
else if(temp2<200000) led=0;
else temp2=0;
break;
//Detected mode
case 3:
temp2+=1;
if(temp2<40000) //LED blink & buzzer activated
{
led=1;
buzzer=1;
}
else if(temp2<60000)
{
led=0;
buzzer=0;
}
else temp2=0;
break;
}
}
}