hye..i new here..i need some help and advice..about pic 16f877a...this year i have a f.y.p(final year project),but now i have problem with my ic circuit.i think my program has true.because i has test it at training kit.my problem is..led is always on..without press the swicth button.??i dont know where the input coming.
What compiler are you using, I dont recognise this
Code:
main ()
{
port B=0b00000000;
port c=0b11110000;
while(1)
{ // You will need statement braces here
if (portc.f7) <- portc.f7 ???
{
port B=0b11111111;
delay_ms (1000);
port B=0;
delay_ms(1000);
}
} //and here
}
thanks ian..but the same think happen..i'm use micro c compiler..
ian,can you give an example using "counter" in programming...simple example is enough..thanks
anyway my program is running well at training kit..but,when i put that same ic in my own circuit...the output pin automatically have voltage reading..i dont know where that voltage come from..i dont really understand about "active high"..and.."active low"...
Ian..one more question..i want a different output at same output port..example..when counter 1 at portb rb7..led on 5 second..when counter 2 at portb rb7..led on 10 second..i want to apply it at alarm system..in my final year project..i do hope u can help me..
If you are going to make an alarm system the counter example needs to be more transparent than it is now, if you look at the example all will work ok but the program will get stuck if the counter is on and stays on... If you need a sensor input then code this differently..
An LED must be current limited.. A PIC can source and sink 25mA on any one pin so they can drive an LED with a current limiting resistor of around 270 ohm.
An output for a siren really needs a transistor driver put a 470 ohm resistor from the output pin to the base of the transistor ( use a 2n222a or similar ) and power a siren up to 100mA.
It means that it is running solo, nothing else can affect it.. For your application you don't need a counter.. I have a similar situation where a switch must do one thing when switched once and another when switched again.. This requires a state machine where the state is monitored in the main loop while other situations are dealt with ie.. Sirens and LED outputs.
The switch de-bounce step in my code is in a simple while(); statement " not good for your application"
Usually active high / low is denoting chip selects or resets etc... pulling the voltage low on an active low input, activates the function.. ie.. on a pic, the reset is active low, so you need to pull it low to reset the chip.