Created
November 14, 2017 10:27
-
-
Save Girgitt/81de1e290fae0b6bd9b8c4f5d5991aec to your computer and use it in GitHub Desktop.
Adruino string and value concat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float v_s_r = analogRead(SUPP_VOLTAGE_PIN); | |
float supp_voltage = (5.0 / 1024) * v_s_r * 3.0; | |
String v_s = "supp_v:"; | |
v_s.concat(supp_voltage); | |
int v_s_str_len = v_s.length() + 1; //we need extra space for the null terminator thus len += 1 | |
char v_s_send[v_s_str_len]; | |
v_s.toCharArray(v_s_send, v_s_str_len); | |
bus.send(200, v_s_send, v_s_str_len - 1); // we don't want to send out the null terminator thus len -= 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment