#include <LiquidCrystal.h>
LiquidCrystal lcd(5,4,3,2,1,0);
void setup()
{
lcd.begin(16,2);
lcd.print("sec");
DDRC=0;
DDRB=0x0f;
PORTC= PORTC|0x03;
TCCR2A = 2;
TCCR2B = 0;
OCR2A = 250;
TIMSK2 = 0;
sei();
Serial.begin(9600);
}
int k=0;
char txt[3];
void loop()
{
if((PINC&0x01)==0){
while((PINC&0x01)==0){}
TCCR2B= 3;
TIMSK2 = 2;
}
else if (Serial.available() >= 2) {
Serial.readBytes(txt, 2);
if (strcmp("OA", txt) == 0) {
PORTB = PORTB|0xFF;
}
else if (strcmp("FA", txt) == 0) {
PORTB = 0;
k=0;
TIMSK2 = 0;
}
}
}
ISR(TIMER2_COMPA_vect){
if(k<2000){
k=k+1;
}
else{
k=0;
PORTB=~PORTB;
}
}