MartinSRB

[НРС] Вежбе 16 - Задатак 5

May 14th, 2023 (edited)
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 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. void serial_check(int id, void* ptrt){
  12.     static int broj1 = -9548, broj2; //lupio sam neku rendom vrednost
  13.     if(Serial.available()){
  14.         if(broj1 != -9548){
  15.             broj2 = atoi(Serial.readString());
  16.             Serial.println(broj1 + broj2);
  17.             Serial.println("Sabiranje zavrseno... Ceka se unos prvog broja: ");
  18.             broj1 = -9548;
  19.         }else if(broj1 == -9548){
  20.             broj1 = atoi(Serial.readString());
  21.             Serial.println("Ceka se unos drugog broja: ");
  22.         }
  23.     }
  24. }
  25.  
  26. void setup()
  27. {
  28.     Serial.begin(9600);
  29.     Serial.println("Ceka se unos prvog broja: ");
  30.     createTask(serial_check, 100, TASK_ENABLE, NULL);
  31. }
  32.  
  33. void loop()
  34. {
  35.  
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment