18 lines
460 B
Arduino
18 lines
460 B
Arduino
|
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 *) ¤t, sizeof(voltage));//float 4bytes
|
||
|
delay(20);
|
||
|
}
|