serialVisualization/serialtest_sender_arduino/serialtest_sender_arduino.ino

20 lines
553 B
Arduino
Raw Normal View History

uint8_t counter=0;
uint16_t value1=65531;
int16_t value2=-123;
float floatvalue=23.42;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN));
Serial.write((uint8_t *) &counter, sizeof(counter));//uint8_t, 1 byte
Serial.write((uint8_t *) &value1, sizeof(value1)); //uint16_t, 2 bytes
Serial.write((uint8_t *) &value2, sizeof(value2)); //int16_t, 2 bytes
Serial.write((uint8_t *) &floatvalue, sizeof(floatvalue)); //float, 4 bytes
delay(500);
counter++;
}