Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float btof(byte * payload, unsigned int length) {
- char * demo = (char *) malloc(sizeof(char) * 10);
- for (int i = 0; i < length; i++) {
- demo[i] = payload[i];
- }
- float value = atof(demo);
- free(demo);
- return value;
- }
- // Callback to handle subscription
- void callback(char* topic, byte* payload, unsigned int length)
- {
- value = btof(payload, length);
- value = map(value, 0, 1023, 0, 180);
- //Map the 0-100 values from the slider to the 0-180 to use the servo lib.
- ESC.write(value);
- //Send the value (PWM) to the ESC
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement