101 question: how do I upload from scratch to mBot


#1

Hi, this feels like a really basic question and I’m afraid the answer is really simple… but I’ve been trying for over an hour to get the scratch-sketch from the getting started sample onto my mBot. Can someone kick me in the right direction? Thanks!

Olaf

ps. I’m using a USB cable and the mbot status thingie shows green, I did update the firmware and install the Arduino driver


#2

You may be better off using the mblock software. While it’s based on Scratch, it is preconfigured to work with the makeblock products.

Are you on Windows, Linux, or Mac? Either one, you want to make sure the devices shows up to the OS and that you’ve chosen the correct serial port.

As a test, can you upload any code with the stock Arduino IDE? That would at least confirm the USB connectivity.


#3

Thanks Shaiss! I am already using the mblock software, apologies for not making that clear from the start. And I did make some progress :slight_smile: I’m familiar with Arduino programming, but not with Scratch (or mblock for that matter) so I did not realize I needed to convert the scratch code to Arduino code and then had to upload that. And I actually tried before posting, but it didn’t work as I hadn’t installed the Arduino IDE on the computer I’m currently using :-/

So to make this topic maybe more useful for other folks just getting started, the solution to the original question seems to be:

  1. make sure you have the Arduino IDE installed (from https://www.arduino.cc/en/Main/Software)
  2. set mblock into Arduino mode (from the menu ‘Edit’)
  3. refresh the Arduino code (took me a while to figure this one out…): move one of the scratch blocks around to force a refresh.
  4. Use the ‘upload to Arduino’ button above the arduino code pane.

Is this indeed the way to go or am I making things too complicated?

I am still fighting with the connection between the mBot and my computer (USB) by the way. Sometimes the bot connects right away and sometimes it simple refuses no matter how often I click the COM port from the ‘Serial Port’ menu. Is that normal behavior?

Olaf


#4

What os? Mac, win, linux?


#5

Windows, running W7


#6

@olbikenk I have a Mac and also have some problems with the connectivity.

Sometimes when I connect the mBot, it seems to go into some start-reset-start cycle. This happens definitively when I have bluetooth shield mounted (so I regularly have to remove it, if I want to use USB), but it sometimes happens even without bluetooth shield attached. I can really observe this behavior when I connect with the factory settings applied to the mBot, since these make sounds and use the RGB lights when the robot starts.

I have observed that the technical USB connectivity has some flaws:

  • If the start-reset-start cycle is in operation, it seems as if I can help it by connecting the power cable to my laptop
  • There are situations when the OSX crashes!!! I get a grey screen with a note on a kernel panic. Later, after reboot, I can read in the kernel crash report that it was in the WCH USB driver were the last activities took place.

Summary: There might be a technical design problem with the USB of the mBot. There might be a USB driver problem. There might be both.


#7

Hi olbikenk, Thank you so much for asking these questions. I had all the same problems like you and have wasted 2 days getting things to move. Windows 7, 8.1 and Linux it all did not work. mBlocks software crashed or froze all the time. For some reason I get more COM port choices each time I unplug an mBot.

Brilliant as I did not found it mentioned on Makeblock website that one has to go from scratchblock (mBlock to the Arduino interface to upload the software. Again how such a crucial piece of information is not featured more prominently is beyond me.

At least this got the mbot moving though not at the speeds I am seeing in the support videos. And yes I am using new AA alkaline batteries. Should I use another kind?

May be of topic here but the bluetooth does not work either. both Windows computers find the card, pair up but that is as far as it goes.

Better instructions would definitely be a plus.


#8

In my experience with Win7 and the mBot with the Bluetooth option, Windows is paired with the mBot Bluetooth, My Win7 names it “Makeblock”. But in the mBlock software under ‘Connect’, you don’t connect as Bluetooth but as Serial port Com 3. If that doesn’t work, go into Windows control panel, change Bluetooth option, and make sure the ‘ELEC’ option is checked. In the ‘Port’ option, port 3 and 5 should already be filled in. Leave the control panel and reboot, it’s Windows. Back in the mBlock software, you should be able to connect using the serial port 3 option.

I’m at the point where I can, apparently, compile and upload my scratch code. But it’s not running the code. Still looking into that.


#9

FYI You can actually run the code from the scratch program on the PC/Mac over USB, bluetooth, Wifi (depending on which you prefer) The downside is that it is pretty slow but the upside is that debugging is near instant. after you work out most of the kinks you can then download it to the mBot as arduino code so it can run “offline”

To test this out connect the mBot to the computer running scratch, connect using your favorite method.
double click on any of the robots items that have a visible or audible effect. if it happens all is set for using the programs that in scratch right away. You can blend other scratch items that aren’t currently supported by the bot but are supported by the computer. Suppose you want to bot the say “Uh Oh!” when the Ultrasonic Sensor detects something. You can record the sound in scratch and play it back on scratch when you run the program this way. I think that is pretty cool.


#10

Unfortunately the bluetooth approach with the ‘ELEC’ option didn’t help here (no ELEC option (?)), but I found out I can work around the connectivity issue over serial by restarting mblock. Far from ideal as this is way too many steps to start programming the bot together with my kids, so I hope we’ll make some progress on this one…


#11

What OS are you using? I am on a Mac (Yosemite) and finally figured out the steps to run programs remotely via Bluetooth.
Step 1 make sure the mblock is installed.
Step 2 You have to pair the bot using the System Preferences. (it won’t stay paired but it will become a device that you can connect to in the mBlock Scratch program)
Step 3 Restart the mBlock program.
Step 4 Open the Connect Menu
Step 5 You should see an additional serial connection option like: /dev/tty.Makeblock-ELETSPP Select that one
Step 6 Confirm that the same item is checked when viewing the Connect Menu again.

You will need to be sure to have mBot selected in the Boards Menu and the Extensions menu.


#12

Thank you, Olbikenk! I was having the same problem. I made a script and it was running fine as long as the MBot was connected via USB. I couldn’t figure out how to upload the program into the MBot. I expected a simple button for that in MBlock. I didn’t realize that I needed to install the Arduino driver first and need to change to Arduino mode. Thanks!