Advertisement
dusanrs

zadatak14

May 19th, 2022
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<arduinoPlatform.h>
  2. #include<tasks.h>
  3. #include<interrupts.h>
  4. #include<stdio.h>
  5. #include<serial.h>
  6. #include<pwm.h>
  7.  
  8. extern serial Serial;
  9. #include<arduinoPlatform.h>
  10. #include<tasks.h>
  11. #include<interrupts.h>
  12. #include<stdio.h>
  13. #include<serial.h>
  14. #include<pwm.h>
  15.  
  16. extern serial Serial;
  17.  
  18. #define PIN1 2
  19. #define PIN2 7
  20. #define PIN3 8
  21. #define PIN4 35
  22.  
  23.  
  24. void setup()
  25. {
  26.    pinMode(PIN1,INPUT);
  27.    pinMode(PIN2,INPUT);
  28.    pinMode(PIN3,INPUT);
  29.    pinMode(PIN4,INPUT);
  30.    for(int i=0;i<8;i++){
  31.         pinMode(26+i,OUTPUT);
  32.    }
  33.  
  34. }
  35.  
  36. void loop()
  37. {
  38.  
  39.  
  40.  
  41.   int brojac=0; // brojim upaljene lampice
  42.  
  43.   if(digitalRead(PIN1)) brojac+=2;
  44.   if(digitalRead(PIN2)) brojac+=2;
  45.   if(digitalRead(PIN3)) brojac+=2;
  46.   if(digitalRead(PIN4)) brojac+=2;
  47.  
  48.   for(int i=0;i<brojac;i++){
  49.     digitalWrite(26+i,HIGH);
  50.     delay(500);
  51.   }
  52.  
  53.   for(int i=0;i<8;i++){
  54.     digitalWrite(26+i,LOW);
  55.  
  56.   }
  57.  
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement