Introduction: Getting Started With MBlock Browser Based Coding for HyperDuino
Welcome to the mBlock web based tutorial with HyperDuino. This is going to show you how to set up mBlock and upload your code to your HyperDuino. This will also show you how to create a basic code for a smart car as well. To start lets jump right into it by clicking HERE.
Step 1: Setting Up MBlock
When it starts to load the webpage you will be prompted to enable the flash player if you have not done that, go ahead and select enable flash and allow it to be run by google chrome. Once that is complete you will be brought to the main mBlock block coding page. We are almost done with the setup! Next it will prompt you to download a plug in which is needed for compiling the code to the actual Arduino/HyperDuino. Go ahead and begin downloading the software. You will see it appear in the bottom left side of your screen as it downloads. If not you can access this by pressing the three stacked dots on the right side of the chrome browser and going to downloads. If it does not appear there make sure you clicked the right button. You will need to run the installer and go through all the steps to complete the installation. After it is all complete you will need to restart the computer as prompted. When loaded back up you should be all ready to go!
Step 2: Tweaking the Setting for Arduino/HyperDuino
Before we begin programing you are going to want to set the mode to Arduino mode and make sure that you are uploading to the right board type. For starters click on edit and press at the very bottom it will say Arduino Mode. It will change the look of the screen but don't be alarmed, this just took out the code that would be useless when programing the Arduino/HyperDuino. Up next you are going to want to change the board that you are uploading too. I am using the Arduino Uno which is what the HyperDuino is mainly paired to, so lets switch it from mBot to Arduino Uno. Lastly we are going to want to set the connection type so it does not get confused with what we are doing when we try to upload it. On the very far right side of the screen go ahead and press the connect tab and select "USB" and make sure it is connected to the proper USB port that the Arduino/HyperDuino is connected to, this may very between different computers. That's it! You have completed the set up for mBlock browser edition. Below will be an example code on how to make a smart car and upload it to the Arduino/HyperDuino.
Step 3: Programing a Smart Car in MBlock
I started by creating 4 blocks to define a forward and backward function for both the wheels. I did this because when making a turn left and turn right function it will be easier and look nice when the robot rotates. I challenge you before looking at the next picture to try out making all 4 of these commands, or even creating a different way to make each motor go forward and backward. Now that we have a both forward and backward command for each motor, lets make a total forward, total backward, left, and right function for it. Technically you can just use one of the forward commands we just made to turn left and right but I like to make one motor go backwards and the other go forwards just to make it look smoother. Now that we have completed that, lets get to the main code. We first want the car to generally drive forward on the start of the program. Then we can add the ultrasonic sensor portion like such. For now I will just leave one example of the ultrasonic sensor part because the best part of code is the creativity that comes with it. See how smart you can make this car. This code will leave it open ended where it will avoid walls yet it still has a possibility to get stuck in places. If you have any questions feel free to leave a comment so I can help you out along the way!