MartinSRB

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

May 12th, 2023
865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 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. void analog(int id, void* ptrt){
  15.     int potencijometar_vrednost = analogRead(analogIn);
  16.     int led_vrednost            = map(potencijometar_vrednost, 0, 1023, 0, 255);
  17.     analogWrite(analogOut, led_vrednost);
  18.     Serial.print("Senzor: ");
  19.     Serial.print(potencijometar_vrednost);
  20.     Serial.print("\tVrednost:");
  21.     Serial.println(led_vrednost);
  22. }
  23.  
  24. void setup()
  25. {
  26.     Serial.begin(9600);
  27.     pinMode(analogOut, OUTPUT);
  28.     createTask(analog, 500, TASK_ENABLE, NULL);
  29. }
  30.  
  31. void loop()
  32. {
  33.  
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment