Professional Documents
Culture Documents
<mega8535.h>
<stdio.h>
<stdlib.h>
<delay.h>
<math.h>
/
#define
#define
#define
#define
kol1
kol2
kol3
kol4
PINB.4
PINB.5
PINB.6
PINB.7
PORTB = 0b11111101;
delay_ms(30);
if (kol1 == 0) {delay_ms(25); lcd_clear();
12"); OCR2=112; delay_ms(25); } //4
if (kol2 == 0) {delay_ms(25); lcd_clear();
40"); OCR2=140; delay_ms(25); } //5
if (kol3 == 0) {delay_ms(25); lcd_clear();
68"); OCR2=168; delay_ms(25); } //6
if (kol4 == 0) {delay_ms(25); lcd_clear();
00"); OCR2=100; delay_ms(25); } //B
lcd_gotoxy(0,1); lcd_putsf("OCR=1
lcd_gotoxy(0,1); lcd_putsf("OCR=1
lcd_gotoxy(0,1); lcd_putsf("OCR=1
lcd_gotoxy(0,1); lcd_putsf("OCR=1
PORTB = 0b11111011;
delay_ms(30);
if (kol1 == 0) {delay_ms(25); lcd_clear();
96"); OCR2=196; delay_ms(25); } //7
if (kol2 == 0) {delay_ms(25); lcd_clear();
24"); OCR2=224; delay_ms(25); } //8
if (kol3 == 0) {delay_ms(25); lcd_clear();
52"); OCR2=252; delay_ms(25); } //9
if (kol4 == 0) {delay_ms(25); lcd_clear();
00"); OCR2=200; delay_ms(25); } //C
lcd_gotoxy(0,1); lcd_putsf("OCR=1
lcd_gotoxy(0,1); lcd_putsf("OCR=2
lcd_gotoxy(0,1); lcd_putsf("OCR=2
lcd_gotoxy(0,1); lcd_putsf("OCR=2
PORTB = 0b11110111;
delay_ms(30);
if (kol1 == 0) {delay_ms(25); lcd_clear(); lcd_gotoxy(0,1); lcd_putsf("CHANG
E LED"); delay_ms(1000); lcd_clear(); indeks=1; PORTD.6=1; } //*
if (kol2 == 0) {delay_ms(25); lcd_clear(); lcd_gotoxy(0,1); lcd_putsf("OCR=
0");
OCR2=0; delay_ms(25); } //0
if (kol3 == 0) {delay_ms(25); lcd_clear(); lcd_gotoxy(0,1); lcd_putsf("CHANG
E LED"); delay_ms(1000); lcd_clear(); indeks=0; PORTD.6=0; } //#
if (kol4 == 0) {delay_ms(25); lcd_clear(); lcd_gotoxy(0,1); lcd_putsf("OCR=
255"); OCR2=255; delay_ms(25); } //D
}
void idks()
{
if (indeks==0)
{
lcd_gotoxy(13,1);
lcd_putsf("2X2");
}
if (indeks>=1)
{
indeks=1;
lcd_gotoxy(13,1);
lcd_putsf("6X6");
}
}
void main(void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0xFF;
DDRB=0x0F;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0xC0;
//
//
//
//
//
Timer/Counter 0 initialization
Clock source: System Clock
Clock value: Timer 0 Stopped
Mode: Normal top=0xFF
OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// 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: 500.000 kHz
// Mode: Fast PWM top=0xFF
// OC2 output: Non-Inverted PWM
ASSR=0x00;
TCCR2=0x6A;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// USART initialization
// USART disabled
UCSRB=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// ADC initialization
// ADC Clock frequency: 31.250 kHz
// ADC Voltage Reference: AVCC pin