samuel_jihn64
Newbie level 3
I'm doing a project using PIC16F877. where if the pic detect smoke from the smoke sensor (input) it will activate the fan (1st output) for 10 second and than activate the 2nd one after the fan which is perfume (2nd Output) to spray. can any one help me check the program i make are correct or not...Thank you so much...
Code:
#include<pic.h> //include PIC microcontroller library
//configuration//
__CONFIG(0x2FF4); //PIC microcontroller configuration
__CONFIG(0x3FFF); //PIC microcontroller configuration
//define declaration//
#define fan_ra RC0
#define perfume_rb RC1
#define sensor RA0
void main()
{
unsigned char m=0,i=0;
ANSEL=0;
ANSELH=0;
//TRIS Configuration (input & output)//
TRISA=0b11111111; //configure PORT B I/O direction
PORTA=0xb00000000; //configure PORT B I/O direction
PORTB=0xb00000000; //configure PORT B I/O direction
while (1)
{
if(sensor==1)
{
fan_ra=1;
delay(10);
perfume_rb=1;
};
}
}