Advertisement
cimona

lab4(zad1+2)

Dec 25th, 2017
2,683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 1.13 KB | None | 0 0
  1. int sveti=128;
  2. int count=0;
  3. int i=0;
  4. int dali = 0;
  5. void znakP(){
  6.      PORTB=0b00110111;
  7. }
  8. void znakC(){
  9.      PORTB=0b00111001;
  10. }
  11.  
  12. main(){
  13. ANSEL=ANSELH=0;
  14. TRISA=0x00;
  15. PORTA=0x00;
  16.  
  17. TRISE=0b0001;
  18. PORTE=0b0000;
  19.  
  20. TRISB=0x00;
  21. PORTB=0x00;
  22.  
  23. while(1){
  24.          if(PORTE.B0==0){
  25.               PORTA=0b00000000;
  26.               znakC();
  27.               if(dali==1){
  28.               EEPROM_Write(0x00,i);
  29.               i++;
  30.               EEPROM_Write(0x00+i,count);
  31.               count=0;
  32.               }
  33.          }
  34.          else if(PORTE.B0==1) {
  35.                dali=1;
  36.                znakP();
  37.                PORTA=sveti;
  38.                count++;
  39.                delay_ms(20);
  40.                sveti/=2;
  41.                PORTA=sveti;
  42.                count++;
  43.                delay_ms(20);
  44.                sveti/=2;
  45.                PORTA=sveti;
  46.                count++;
  47.                delay_ms(20);
  48.                sveti*=2;
  49.                PORTA=sveti;
  50.                count++;
  51.                delay_ms(20);
  52.                sveti/=2;
  53.                if(sveti==0){
  54.                   sveti=128;
  55.                }
  56.          }
  57.  
  58.  
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement