I was wondering if anyone has access to the source code for the original firmware that is installed when you select “Reset Default Program”?
I think we could learn a lot from it.
Source code for the Default Program
Adding new functionality to Mbot with out disturbing existing functions
My bet would be on https://github.com/Makeblock-official/mBot/tree/master/mBot-default-program
I have built a close approximation of the “A” driving part of the default mBot program.
When you boot the program it gives you 3 rising tones with a short one at the end.
You set the speed 1-9 (0 is fastest, 1 is slowest) and you get a appropriate short tone for the selected speed.
You use the arrows to go forward, reverse, turn left or right with led colors indicating your actions.
At speed 1 you might not get any motion since it is right at the motor’s minimum voltage.
It defaults to speed 5.
I plan to enhance this program with line following, wall avoidance, and other options in my exploration of this cool robot.
Zip file of scratch code source: drive_prog.sb2.zip (236.6 KB)
mBOT Source Code
Can't reprogram remote control
I ran into a few interesting issues with the scratch to arduino code translation that needs to be addressed and will break my code when fixed.
Upon close inspection I have the initialization of the variables reversed due to the fact that when the scratch code is converted to arduino cpp it reverses the order. Also note the shuffling of tones after the variable initialization even though they are set after the first two tones and before the third.
The other issue was that varaibles and blocks can’t have spaces in the names since they will either cause compilation errors or items will get the wrong name. Just use an underbar ‘_’ to separate words in variable and block names.
Hello Danjger,
you have mentioned some issues with the scatch to arduino code translation.
If I understand correctly, these issues have to be fixed by makeblock in an upcoming release.
Just curious: Are you in contact with the Makeblock developers on this? Maybe you could give a brief update on the status?
Many thanks!
I am not in contact with them except via this forum. I have posted the bugs in another thread but that thread seems to have been deleted. I’m not sure they are aware of the ill will their lack of participation here is causing.
It’s clear that the Makeblock team, however large it may be, doesn’t have any folk dedicated to ongoing customer support.
I really enjoy the mBot and have had good success with many older Makeblock products. But it’s depressing to run across detailed questions from users and customers languishing in unread comment sections and this forum.
There needs to be a good wiki. Some real tutorials and a project sharing space would really help. IMHO
Hi @danjger,
Thank you for sharing this, much appreciated.
Did you ever get to the ultrasonic part by any chance?
Thanks,
Stefan
I have not, sorry. I do think it would be simple so I can see about doing it over the next few weeks.
There may be others that have already done it. I know @chuckmcknight had worked on a more advanced version that solves a maze.
I updated your script and added ultrasonic and sound sensor inputs that trigger motors and led lights actions. I’'m about to add light detection and i’ll post my result here later.
Thanks again.
I ended up not doing the Factory Default program, but another multi behaviors (A,B,C,D) one.
Big thank you to Charles McKnight (@chuckmcknight) for his book: A Gentle Introduction To Robotics With mBlock and mBot - which i highly recommend buying and reading. No way i could do this without it.
Hope this can help.
Multi_Programs_v03b.sb2 (76.2 KB)
Some details
Multi_Programs
Shared across:
- Initialize
- Set Speed (IR remote 0 to 5)
- Mode setting (IR remote A,B,C …)
——
Set speed on IR remote:
0 = 0
1 = 50
2 = 100
3 = 150
4 = 200
5 = 255
——
Mode A: Simple Drive
You take control of the movement (motors) using the IR remote. That’s all it does.
Mode B: Speed Tool
Tool to evaluate the real speed of your very own mBot. Create a chart table and measure the distance ran by the robot when at a chosen speed (Chose speed with IR remote numeric pads 0 to 5). Based on a lesson (/chapter) from Charles McKnight’s book.
I should add the rotation tool as well (same source), so that rotations can be given in degrees (as opposed to timing, which would change the amount of rotation depending on the speed)
Mode C: Ultrasonic Auto Drive Mode
For this 1st simple version it always turns right when there is an obstacle.
The ‘turn right’ is set for a period of time = turn right for 0.3sec
The next step is to implement turns in degrees.
Mode D: Arena Game
Arena = Based on BashinAtTheBasho (Charles McKnight’s book).
stay inside an “arena” (surrounding outlined field, walls, fence?) and charge if an objected is detected at a preset distance (range).
Mode E:
Move backward for a short amount of time. Dummy program for you to play around.