Hi,
My project use the “timer” and “read ultrasonic sensor …”.
When I want to upload to Arduino, I got the Error.
NG_Extensions.sb2 (73.0 KB)
Hi,
My project use the “timer” and “read ultrasonic sensor …”.
When I want to upload to Arduino, I got the Error.
NG_Extensions.sb2 (73.0 KB)
@tec_support, there is an error in the code generator. It failed to declare vt and also failed to put in the closing brace on the getLastTime() method (see corrected code below:
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
double vu;
double vt; // <--- added declaration for vt
float getDistance(int trig,int echo){
pinMode(trig,OUTPUT);
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig,HIGH);
delayMicroseconds(10);
digitalWrite(trig,LOW);
pinMode(echo, INPUT);
return pulseIn(echo,HIGH,30000)/58.0;
}
double currentTime = 0;
double lastTime = 0;
double getLastTime(){
return currentTime = millis()/1000.0 - lastTime;
} // <---- added closing brace
void setup(){
vu = getDistance(13,12);
vt += getLastTime();
}
void loop(){
_loop();
}
void _delay(float seconds){
long endTime = millis() + seconds * 1000;
while(millis() < endTime)_loop();
}
void _loop(){
}
Hi wpopoily & Charles,
We have verified this issue and added it to the repair list.
Thanks for your feedback!
Hi chuckmcknight,
Yes, I can do it by Arduino IDE.
But children can’t correct it by themselves, they don’t know the Arduino IDE.
Hi tec_support,
That is great!
And about the other feekback - "When use “Timer”feature, the mBlock 3.4.5 something wrong"
Whether the mblock team also verified it !?
Hi @wpopoily,
Yup, that’s why I copied in @tec_support because it is an issue in the code generator. It is fixable in the Arduino IDE, but the bug really needed to be reported.
Regards,
Chuck
Hi wpopoily,
Thanks! I have provide feedback about this one to our engineers either.
Will let you know when get the reply.
Hi mBlock team,
The v3.4.8 still lose the closing brace.
The problem has been a long time.
Could you solve this problem?
Thank you very much.
Hi wpopoily,
Actually, our engineers have fixed this issue, but it still cause losing the closing brace on the other program block.
Hopefully we can fix it on the next version,thanks for your feedback!
Actually, I have many the customized blocks(function) to do something in my project.
So I very much hope that the problem can be solved earlier.
Now, I try v4.0.1 seems to fix it.
But the v4.0.1 has a problem, there is no “Save” prompt,
before the program leaves or loads other projects.
Yes, there is no “Save” prompt on v4.0.1, while there is plan to add the undo function in the future.