Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char msg_buffer[60];
- float temperature = 10.5;
- void setup()
- {
- Serial.begin(9600);
- char temp_str[15] = {0};
- dtostrf(temperature, 4, 1, temp_str);
- char *space = strchr(temp_str, ' ');
- if (space != NULL) {
- *space = '\0';
- }
- sprintf(msg_buffer, "Temperature: %s", temp_str);
- Serial.println(msg_buffer);
- pinMode(13, OUTPUT);
- }
- void loop() {}
- /* alternative setup() */
- void setup() {
- Serial.begin(9600);
- //create String object from float with 1 decimal place
- //will be heap-allocated
- String output = "Temperature " + String(temperature, 1);
- Serial.println(output);
- pinMode(13, OUTPUT);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement