Any program that tries to light up the mBot’s on-board lights will only light up one of them, and will light the wrong color. The number for red goes to green, green goes to blue, and it’s impossible to use blue. For instance, this will light one LED bright blue:
mBlock 3.1 lights wrong LEDs on mBot via 2.4G
@samkass
I just updated both the mBlock software and the mBot firmware and your sketch works fine for me. Double check your updates and try again. Good Luck.
I just tried connecting it via USB serial and clicking “Upgrade Firmware” then “Reset Default Program”, then turning the mBot off, disconnecting the USB cable, turning it on, and connecting via 2.4G. I then run the above program and get one bright blue light again.
I’m using the Mac version of mBlock v3.1, but a kid in the class had the same behavior with his Windows version of v3.0.
Apparently the trick is NOT to select “Reset Default Program”. When I just “Upgrade Firmware” it works fine. When I “Reset Default Program” I get the bad behavior again.
It is my understanding that the “Default Program” is just that, a program (or Sketch) that has it’s own set of commands. The mBot can only have one sketch running at a time. So if you run your sketch, and then load the “Default Program”, your sketch is not what is running. Also, the “Default Program” has code that responds to 2.4G commands, where your sketch does not.
That is what I thought, too, but it does not appear to be the case. After just “Upgrade Firmware” with v3.1, the mBot responded to 2.4G commands perfectly. I haven’t tried the remote control yet. The “Default Program” is what I used to recommend for the class, since we do most of our work connected in 2.4G mode. (They are 8-12 years old, so I don’t want to expose any C++ yet.) But now the “Default Program” seems to cause glitches like the LED problems (also won’t respond to 7-segment-display commands).
I found the bug in the firmware that caused this problem.
Open MeRGBLed.cpp in Arduino editor.
Goto line 141
Replace
void MeRGBLed::setColor(uint8_t red, uint8_t green, uint8_t blue)
by
void MeRGBLed::setColor(uint8_t index,uint8_t red, uint8_t green, uint8_t blue)
Save
Connect mBot to computer
Open mBlock and choose Upgrade Firmware
You’re done
Open mBlock
Menuitem: Extensions
Submenu: Manage Extensions
Choose mBot --> View Source
It opens the file location
Choose src-directory
Here is the file
Thanks for the fix.
My Arduino editor does not open .cpp files.
Do you have any ideas as to how to proceed?