i am Trying to build a very basic circuit, the working is as follows:
operating voltage is 3.3Vdc
1. Press switch 1- LED starts to Toggle
2. Press Switch 2- Stop the toggle
3. Long press Switch 2- LED blink 5 times.
i used 18F4520 and it worked (But a costly solution) so i switched to 12F510 but not able to program., not able to figure out the issue.
Can someone kindly help me with the code or any analog circuit.
#fuses INTRC,NOWDT,MCLR //,PROTECT
#use delay(clock=8000000)
void main()
{
while(True)
{
if ( input(PIN_B2) == 0)
{
while(True)
{
output_toggle(Pin_B0);
delay_ms(500);
if( input(Pin_B1) == 0)
break;
}
}
output_low(Pin_B0);
if(input(Pin_B1) == 0 && delay_ms(3000))
{
output_high(Pin_B0);
delay_ms(100);
output_low(Pin_B0);
delay_ms(100);
output_high(Pin_B0);
delay_ms(100);
output_low(Pin_B0);
delay_ms(100);
output_high(Pin_B0);
delay_ms(100);
output_low(Pin_B0);
delay_ms(100);
}
}
}
operating voltage is 3.3Vdc
1. Press switch 1- LED starts to Toggle
2. Press Switch 2- Stop the toggle
3. Long press Switch 2- LED blink 5 times.
i used 18F4520 and it worked (But a costly solution) so i switched to 12F510 but not able to program., not able to figure out the issue.
Can someone kindly help me with the code or any analog circuit.
#include <18f4520.h>#fuses INTRC,NOWDT,MCLR //,PROTECT
#use delay(clock=8000000)
void main()
{
while(True)
{
if ( input(PIN_B2) == 0)
{
while(True)
{
output_toggle(Pin_B0);
delay_ms(500);
if( input(Pin_B1) == 0)
break;
}
}
output_low(Pin_B0);
if(input(Pin_B1) == 0 && delay_ms(3000))
{
output_high(Pin_B0);
delay_ms(100);
output_low(Pin_B0);
delay_ms(100);
output_high(Pin_B0);
delay_ms(100);
output_low(Pin_B0);
delay_ms(100);
output_high(Pin_B0);
delay_ms(100);
output_low(Pin_B0);
delay_ms(100);
}
}
}
Last edited: