/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.3 Standard
Automatic Program Generator
© Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 18.10.2014
Author : PerTic@n
Company : If You Like This Software,Buy It
Comments:
Chip type : ATtiny13A
AVR Core Clock frequency: 0,018750 MHz
Memory model : Tiny
External RAM size : 0
Data Stack size : 16
*****************************************************/
#include <tiny13a.h>
#include <delay.h>
char count;
char i;
char hold;
char w = 1;
char push;
/******************************РАБОТА ПРОГРАММЫ**********************/
// Timer 0 output compare A interrupt service routine
interrupt [TIM0_COMPA] void timer0_compa_isr(void)
{
count++;
if (count > 5)
{count = 0;
}
}
// Declare your global variables here
char not(char w)
{
push = 0;
while (w == 0)
{
if (PINB.0 == 0)
{
push++;
}
if ((PINB.0 == 1) && (count > 3) && (push >3))
{
push = 0;
count = 0;
}
if ((push == 5) && (count < 5))
{
for (i = 0; i < 4; i++)
{
PORTB.2 = 1;
delay_ms(200);
PORTB.2 = 0;
delay_ms(200);
}
push = 0;
hold = 0;
w = 1;
};
};
return w;
};
void main()
{
// Declare your local variables here
// Crystal Oscillator division factor: 256
#pragma optsize-
CLKPR=0x80;
CLKPR=0x08;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif
// Input/Output Ports initialization
// Port B initialization
// Func5=In Func4=In Func3=In Func2=Out Func1=Out Func0=In
// State5=T State4=T State3=T State2=0 State1=0 State0=P
PORTB=0x01;
DDRB=0x06;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 0,073 kHz
// Mode: Normal top=0xFF
// OC0A output: Disconnected
// OC0B output: Disconnected
TCCR0A=0x00;
TCCR0B=0x04;
TCNT0=0x00;
OCR0A=0x49;
OCR0B=0x00;
// External Interrupt(s) initialization
// INT0: Off
// Interrupt on any change on pins PCINT0-5: Off
GIMSK=0x00;
MCUCR=0x00;
// Timer/Counter 0 Interrupt(s) initialization
TIMSK0=0x04;
// Analog Comparator initialization
// Analog Comparator: Off
ACSR=0x80;
ADCSRB=0x00;
DIDR0=0x00;
// ADC initialization
// ADC disabled
ADCSRA=0x00;
// Global enable interrupts
#asm("sei")
while (1)
{
if (w == 1)
{
while (w == 1)
{
if (PINB.0 == 0)
{
push++;
};
while (PINB.0 == 0)
{
PORTB.1 = 1;
};
hold = 1;
PORTB.1 = 0;
if ((push == 5) && (count < 5))
{
for (i = 0; i < 4; i++)
{
PORTB.2 = 1;
delay_ms(200);
PORTB.2 = 0;
delay_ms(200);
};
push = 0;
hold = 0;
w = 0;
};
};
}
else
{
w = 0;
not(w);
};
};
};