thomazrb icon

Arduino 2

thomazrb | PRO | 12/08/17 06:24:40 PM UTC | 0 ⭐ | 485 👁️ | Never ⏰ | []
C++ |

630 B

|

None

|

0 👍

/

0 👎

// Valores de temp x 10
int tempMin = 359;
int tempMax = 369;
int tempInicial = 365;
 
// Valores de bpm
int bpmMin = 40;
int bpmMax = 100;
int bpmInicial = 60;
 
float temp = tempInicial/10.0;
int bpm = bpmInicial;
 
void setup() {
  Serial.begin(9600);
}
 
void loop() {
  
  temp = temp + random(-1, 2) / 10.0;
  
  if (temp * 10 > tempMax)
    temp = tempMax/10.0;
  if (temp * 10 < tempMin)
    temp = tempMin/10.0;
 
  bpm = bpm + random(-1, 2);
 
  if (bpm > bpmMax)
    bpm = bpmMax;
  if (bpm < bpmMin)
    bpm = bpmMin;
 
  Serial.print(temp);
  Serial.print(" ");
  Serial.println(bpm);
  delay(5000);
 
}

Comments