Advertisement
thomazrb

Arduino 2

Dec 8th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. // Valores de temp x 10
  2. int tempMin = 359;
  3. int tempMax = 369;
  4. int tempInicial = 365;
  5.  
  6. // Valores de bpm
  7. int bpmMin = 40;
  8. int bpmMax = 100;
  9. int bpmInicial = 60;
  10.  
  11. float temp = tempInicial/10.0;
  12. int bpm = bpmInicial;
  13.  
  14. void setup() {
  15.   Serial.begin(9600);
  16. }
  17.  
  18. void loop() {
  19.  
  20.   temp = temp + random(-1, 2) / 10.0;
  21.  
  22.   if (temp * 10 > tempMax)
  23.     temp = tempMax/10.0;
  24.   if (temp * 10 < tempMin)
  25.     temp = tempMin/10.0;
  26.  
  27.   bpm = bpm + random(-1, 2);
  28.  
  29.   if (bpm > bpmMax)
  30.     bpm = bpmMax;
  31.   if (bpm < bpmMin)
  32.     bpm = bpmMin;
  33.  
  34.   Serial.print(temp);
  35.   Serial.print(" ");
  36.   Serial.println(bpm);
  37.   delay(5000);
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement