/***************************************************** This program was produced by the CodeWizardAVR V2.04.4a Advanced Automatic Program Generator © Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : Drums Version : 1.0 Date : 16.07.2012 Author : Serj Company : Comments: Chip type : ATmega8 Program type : Application AVR Core Clock frequency: 8,000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/ #include #include bit a=0, b=0, c=0, d=0, e=0, f=0, g=0, h=0, i=0, j=0, k=0, l=0; void main(void) { // Declare your local variables here // Input/Output Ports initialization // Port B initialization // Func7=Out Func6=Out Func5=In Func4=In Func3=In Func2=Out Func1=Out Func0=Out // State7=0 State6=0 State5=P State4=P State3=P State2=0 State1=0 State0=0 PORTB=0x38; DDRB=0xC7; // Port C initialization // Func6=In Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out // State6=P State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 PORTC=0x40; DDRC=0x3F; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=P State6=P State5=P State4=P State3=P State2=P State1=P State0=P PORTD=0xFF; DDRD=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped TCCR0=0x00; TCNT0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer1 Stopped // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x00; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped // Mode: Normal top=FFh // OC2 output: Disconnected ASSR=0x00; TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off MCUCR=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; while (1) { a=PIND.0; b=PIND.1; c=PIND.2; d=PIND.3; e=PIND.4; //Считывам в переменные состояния пинов f=PINB.5; g=PINB.4; h=PINB.3; i=PIND.5; j=PIND.6; k=PIND.7; if((a+b+c+d+e+f+g+h+i+j+k)>0) //если хоть один равен 1 {PORTC.4=a; PORTC.5=b; PORTC.3=c; //выводим все в порт PORTC.2=d; PORTC.1=e; if((f+g)>0) //Присваиваем переменной l значение переменных {l=1;} PORTB.6=l; // Выводим в порт #asm("nop") PORTB.2=h; PORTB.1=i; //Выводим в порт PORTB.0=j; PORTB.7=k; delay_ms(25); //Ждем PORTB=0; PORTC=0; //Все выключаем } }; }