PikaBot is a mobile robot kit based on Maker UNO (Arduino UNO compatible). It allows users to learn electronics, sensors, microcontrollers, and coding while having fun. It also comes with a comprehensively designed box that can be used as the mobile robot base and cover!
mBlock is a programming software tool developed based on Scratch 3.0 and Arduino code. It allows kids to learn programming using block-based programming language.
I had created an extension for PikaBot in mBlock to let users without electronics or programming knowledge to start coding and learn robotics in a fun and easy way.
This is the first lesson (move around) for this series. Check out the other lessons in the links below:
- Program Arduino Mobile Robot Using mBlock | 2 Detect Object
- Program Arduino Mobile Robot Using mBlock | 3 Line Follow
ONLINE VERSION
Step 1: Go to mBlock web code editor
Go to mBlock web code editor at: https://ide.mblock.cc/
Step 2: Add PikaBot device extension
Click on device in left panel
Click on the add button and choose PikaBot extension
OFFLINE VERSION
Step 1: Download and install mBlock5
Download mBlock5 software at: https://www.mblock.cc/en-us/download/
Click on the downloaded file to install mBlock5 software
Step 2: Add PikaBot device extension
Click on device in left panel
Click on the add button and choose PikaBot extension
CODING
Drag and drop when pikabot starts up
block from Events
category.
Intialtize the motors by drag initialize left motor...
block from Motor
category and drop it under when pikabot starts up
block.
Default motor pins for PikaBot is:
- M1A - 11
- M1B - 10
- M2A - 9
- M2B - 3
Change the pin values if you are NOT using default pins as mention in PikaBot manual.
Dragmove forward 100
, and brake
from Motor
category, wait 1 second
from Control
category, drop the blocks as shown below.
move forward
block value is the speed of the motors. The value should between 0 to 100
with 100 as full speed.
brake
block stops the PikaBot.
UPLOAD
Connect USB cable from your PC to PikaBot. Make sure it is in 'Upload' mode and click on the 'Connect' button on bottom left in mBlock.
Then choose the correct COM port for your device, and click connect.
Then click on the upload button and wait for it to upload the program to PikaBot.
TESTING
MORE PROGRAMMING
Program the blocks as shown below
left motor move...
block value is the speed and direction of the motor. positive value to move forward and negative value to move backward. '0' for brake and '100' for full speed.
- PikaBot will move forward in full speed for 2 seconds
- Then turn left in '50' speed for 1 second
- Then turn right (left motor move forward in '50', right motor move backward in '-50') for 1 second
- Then move backward in full speed for 2 seconds
This program will run PikaBot continuously until the power is switched off because these blocks are inside forever
block, which is equivalent to 'void loop()' in Arduino IDE.
Comments