That processor i used is a PIC16F628A, it mean no need to add LAT function.
That code are working very well, there are 2 mode function, latch and momentary, for latch function that working well, momentary also working well too for only run 1 LED, but if I run for 2 LED, that problem the other LED can't follow when toggle is pressed.
Well, let me detail the code of problem, here are :
do
{
if(SELECTOR == 1) // Selector switch momentary is on pos
{
LED_Momentary = 1; //Led UP
LED_Latching = 0; // Led DOWN
{
if (Button(&PORTA, 0, 10, 1)) // you can set the debouncing delay directy in this function (10ms)
{
oldstate0 = 1; //Put it high once release
}
if (oldstate0 && Button(&PORTA, 0, 10, 0))
{
LED0 = ~LED0;
oldstate0 = 0;
}
}
}
else
{
If only 1 LED0 that function is okay, but I wish to add LED1, it mean when the button is toggle then LED0 is off and LED1 is on then one more toggle or release LED0 is on and LED1 is Off.
Below code :
if(SELECTOR == 0) // Selector switch latch is on pos
LED_Latching = 1; //Led UP
LED_Momentary = 0; //Led DOWN
if (Button(&PORTA, 0, 10, 1)) // you can set the debouncing delay directy in this function (10ms)
{
oldstate0 = 1;
LED0 = 0; // Once selected led Off
LED1 = 1; // Led up
}
if (oldstate0 && Button(&PORTA, 0, 10, 0))
{
oldstate0 = 0;
LED0 = 1;
LED1 = 0;
}
}
} while (1);
}
Are fine, no problem the function is working well.
Galee.