|
|
View previous topic :: View next topic |
Author |
Message |
andys
Joined: 23 Oct 2006 Posts: 175
|
switch |
Posted: Wed Jan 10, 2007 4:06 pm |
|
|
I try to create a switch circuit from microcontroller which must to light on a led on pin B0 and light off a led on pin B1 when the input is ==0 and light on a led on pin B1 and light off a led on pin B0 when input is >0
i wrote the code bellow but the problem is that only the LED on pin B0 is light on unless the input is >0 and still light on for all the value of input
if (input(PIN_A0)==0){
delay_ms(10);
output_bit(PIN_B0,1);
output_bit(PIN_B1,0);
}
else{
delay_ms(10);
output_bit(PIN_B0,0);
output_bit(PIN_B1,1);
}
IS anyone know what is the problem???????? |
|
|
Ttelmah Guest
|
|
Posted: Wed Jan 10, 2007 4:42 pm |
|
|
It is probably the classic PIC RMW problem (read modify write).
Have a look in the PIC data sheet, and a search on this forum, for these three words, and you should find a number of threads where this is described, as well as fixes for it. It is actually a hardware problem with the chip, especially when there is a significant load on an output pin (what resistors are you using to current limit the LED's).
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|