When I use mBot or other device based on Arduino, How to set the variable by float or int?


#1

When I use variable in mblock, the variable is float type, I can check the C code. But When I set the variable by number on block editor, the value is string type. How to set the variable by float or int?
See the codes blow:
//When I edit block, the codes are translated to c code automatically

float d = 0;
void setup() {
d = “0”; //compile error!! How can I set float or int value?
}


#2

mblock variables are horribly implemented. You can use a numerical operator… something like this:
image


#3

Look at the extension AdvancedArduino. Maybe, it helps.

phg