MartinSRB

[НРС] Вежбе 15 - Задатак 2

May 12th, 2023
846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  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. #include<data.h>
  8.  
  9. extern serial Serial;
  10.  
  11. int analogIn = A0;
  12. int analogOut  = 33;
  13.  
  14. int startTime = 0;
  15.  
  16. void analog(int id, void *ptrt){
  17.     int potencijometar_vrednost = analogRead(analogIn);
  18.     int led_vrednost            = potencijometar_vrednost * 6;
  19.     if(millis() - startTime < led_vrednost){
  20.         digitalWrite(analogOut, HIGH);
  21.     }else if(millis() - startTime < (6*1024)){
  22.         digitalWrite(analogOut, LOW);
  23.     }else{
  24.         startTime = millis();
  25.     }
  26. }
  27.  
  28. void setup()
  29. {
  30.     pinMode(analogOut, OUTPUT);
  31.     startTime = millis();
  32.     createTask(analog, 6, TASK_ENABLE, NULL);
  33. }
  34.  
  35. void loop()
  36. {
  37.  
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment