Advertisement
dusanrs

zadatak23

May 21st, 2022
153
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.  
  10. #define LD8 33
  11.  
  12. #define PIN1 2
  13. #define PIN2 7
  14. #define PIN3 8
  15. #define PIN4 35
  16.  
  17.  
  18. int blink_id1,blink_id2;
  19.  
  20. void blink_task1(int id,void *tptr){
  21.     digitalWrite(LD8,!digitalRead(LD8));
  22. }
  23.  
  24. void blink_task2(int id,void *tptr){
  25.     int brojac=0;
  26.     if(digitalRead(PIN1)==HIGH) brojac++;
  27.  
  28.  
  29.     if(digitalRead(PIN2)==HIGH) brojac++;
  30.  
  31.  
  32.     if(digitalRead(PIN3)==HIGH) brojac++;
  33.  
  34.  
  35.     if(digitalRead(PIN4)==HIGH) brojac++;
  36.  
  37.     setTaskPeriod(blink_id1,brojac*100); // mora se direktno proslediti f-ji taj id
  38.  
  39.  
  40. }
  41.  
  42.  
  43. void setup()
  44. {
  45.     pinMode(LD8,OUTPUT);
  46.     blink_id1=createTask(blink_task1,100,TASK_ENABLE,NULL); // na svakih 100ms pali i gasi LD8
  47.     blink_id2=createTask(blink_task2,1000,TASK_ENABLE,NULL);
  48. }
  49.  
  50. void loop()
  51. {
  52.  
  53.  
  54.  
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement