Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <reg515.sfr>
- #include <lcd.h>
- int tablicaP1[6] = {222, 219, 249, 237, 231, 246};
- int hallotron[6] = {3, 1, 5, 4, 6, 2};
- int czestotliwosc = 100;
- int limp;
- int licznik = 0;
- int kierunek = 0;
- main() {
- int i = 0;
- unsigned char znak;
- unsigned int liczba = 0;
- int enterPressed = 0;
- EAL = 1;
- ET2 = 1;
- T2I0 = 1;
- T2R1 = 1;
- lcd_init();
- out_instr(0x01);
- while(1)
- {
- znak = get_kb();
- if(znak != '\0')
- {
- if(znak >='0' && znak <='9')
- {
- liczba = liczba*10 +(znak-48);
- out_char(znak);
- }
- if(znak == 'p')
- {
- kierunek = 0;
- }
- if(znak == 'l')
- {
- kierunek = 1;
- }
- if(znak == 'e')
- {
- enterPressed = 1;
- out_instr(0x01);
- out_instr(0xC0);
- out_char(liczba);
- czestotliwosc = liczba;
- if (czestotliwosc < 100 && czestotliwosc > 500)
- {
- czestotliwosc = 100;
- }
- limp = 0xFFFF - 1000000 / czestotliwosc;
- CRCH = limp >>8;
- CRCL = limp;
- liczba = 0;
- out_instr(0x10);
- }
- if(enterPressed == 1)
- {
- out_instr(0x80);
- enterPressed = 0;
- }
- }
- for(i=0;i<15000;i++);
- }
- }
- _interrupt 5 void int_T2(void)
- {
- while((P4&7) == hallotron[licznik])
- {
- TF2 = 0;
- if (kierunek == 0)
- {
- licznik++;
- if(licznik > 5)
- licznik = 0;
- P1 = tablicaP1[licznik];
- }
- if (kierunek == 1)
- {
- licznik--;
- if(licznik < 0)
- licznik = 5;
- P1 = tablicaP1[licznik];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement