Hello,
I am trying to turn LED on GP1 if I press push button on GP2 2 times, and if I press it 3 times I would like to turn LED on GP4. Is this a good way to start?
I am trying to turn LED on GP1 if I press push button on GP2 2 times, and if I press it 3 times I would like to turn LED on GP4. Is this a good way to start?
Code:
void main() {
/* Project name:
Detect low voltage
* Description:
Car direction indicators
* Test configuration:
MCU: PIC12F629
Dev.Board: EasyPIC5
Oscillator: 04.0000 MHz, Internal
SW: mikroC PRO for PIC
*/
unsigned char i;
bit oldstate; // Old state flag
{
CMCON = 0b00000111; // disable comparators
GPIO = 0b00000000;
TRISIO = 0b00000100; // gp2= input, gp1, gp4 = outputs
OPTION_REG = 0b11110100; // Counter TMR0 receives pulses through the RA2 pin, Prescaler rate is 1:32
TMR0 = 0 ;
while (1)
{
if (TMR0 == 2) // while GP2 is switched 2 times turn on gpio.F1
{
gpio.F1 = 1;
}
if (TMR0 == 3) // while GP2 is switched 3 times turn on gpio.F4
{
gpio.F4 = 1;
}
}
}
}