serialVisualization/visualizationtest/testsender/testsender.ino

18 lines
460 B
Arduino
Raw Permalink Normal View History

2019-06-09 21:23:02 +00:00
float voltage=50.2;
float current=0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
}
void loop() {
digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN));
voltage=constrain(voltage+random(-10,11)/100.0, 10*3.3,12*4.2);
current=constrain(current+random(-40,41)/10.0, 0,50);
Serial.write((uint8_t *) &voltage, sizeof(voltage));//float 4bytes
Serial.write((uint8_t *) &current, sizeof(voltage));//float 4bytes
delay(20);
}