RoboticsGeneral

Maqueen; code in Mind+ not running as it should

userHead Account cancelled 2019-09-01 07:27:46 2408 Views1 Replies
Hello DFRobot community,
I've been evaluating Maqueen robot in order to use it with my students at school. Everything is good so far using Mind+ application to program Maqueen.
I did have a strange problem with the code attached:
When starting, it should wait 2 seconds then stars turning in place maqueen, while waiting for a brightness > 50.
When testing on maqueen (after uploading), the robot waits for 2 seconds, THEN starts moving forward for about 2 seconds, then starts the "forever loop" and continues OK.
Any advice about this problem?
Thank you very much.

PS: I tried to attach an image of the code, but it keeps giving an error! Here is a copy of the generated code:

#include <Maqueen_Motor.h>
#include <Microbit_Matrix.h>

Maqueen_Motor motor;

void setup() {
motor.motorStop(motor.LEFT);
motor.motorStop(motor.RIGHT);
delay(2000);
}

void loop() {
motor.motorRun(motor.LEFT,motor.CW,35);
motor.motorRun(motor.RIGHT,motor.CCW,35);
if (((MMatrix.readLightLevel()) > 50)) {
motor.motorRun(motor.LEFT,motor.CW,75);
motor.motorRun(motor.RIGHT,motor.CW,75);
delay(2000);
motor.motorStop(motor.LEFT);
motor.motorStop(motor.RIGHT);
delay(1000);
}
}