This is prepared on 02 October 2016, and I don't know if it will still be compatible to future versions.
Trying my new Mbot with my 4 yo daugher, I have seen that a simple programme is not what a child is excited about.
So instead, I studies on how to make changes to default Mbot firmware, and then, successfully managed to do that.
Now my Mbot does everything on default basis, plus some more:
1- A mBot standard servo is attached to Port 4, and is controlled on start-up and some events.
Servo rotates back and forth once at the start-up
When you press 9, in does the same back/forth effect
When you press 8, servo rotates to a specific angle.
When you press 7, servo rotates to 90 degrees angle.
2- I have added a new code to prevent falling down from table. This requires the table to be white and the ground to be dark. I can't say it works perfect, but still it works good enough to demonstrate.
So I have set the "1" on Remote Control to activate this mode.
Pressing A / B / C buttons on the remote, cahnges back to default A / B / C modes.
3- Some automation also have been added to servo Motor on the "prevent falling" sub.
so when the bot is coming to an edge of the table, it does not only turn back, but it also flips the servo to show what it is doing.
the code is simple to understand; what is complex is the included files.
Follow the steps below to see how to work with Servo motor with the default mBot code.
First of all you need to download Wire.zip file here: http://public.adrena.com.tr/mBot/Wire.zip
What you need to do is extract the zip file and copy all the files to your wire folder under something like this:
C:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\Wire
The drive letter or folder may change. But the folder is "mBlock\Arduino\hardware\arduino\avr\libraries\Wire"
If you are asked to replace existing file, you don't need to replace them!
Do not worry to do something wrong, because you are not changing "your" original default mbot software. So whenever you start mBlock editor, and connect to your mBot, you can return to "your original" defaults by going to Connect Menu -> Reset Default Program - mBot
After the files are copied, you are now able to edit the default mBot software. You can also download that one here: http://public.adrena.com.tr/mBot/mbot_ORG.txt
Open the Arduino Editor and copy all mbot_ORG.txt and paste them to a new empty project.
Now when you compile the file, you should see no errors. (So all the include files are in place)
My code that controls Servo motor additional to default mBot software can be downloaded from:
http://public.adrena.com.tr/mBot/mBotDefServ.txt
If you download the .txt file and save it, and then rename it to mBotDefServ.ino then you can directly open it in Arduino Editor.
Another way is to open the txt file, and select all by CTRL-A, and copy (CTRL-C), and paste all in the Arduino editor.
Cheers....
Thanks to my daughter who gave me a lot of ideas about what a bot needs to do and how it should act.
Alper & daughter Karin
41yo & 4yo