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 second lesson(detect object) for this series.Check out the other lessons in the links below:
- Program Arduino Mobile Robot Using mBlock | 1 Move Around
- 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
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. Click here to learn how to use Motors for PikaBot
Initialize the ultrasonic sensors by drag initialize ultrasonic:...
block from Sensors
category and drop it under initialize left motor...
.
Default ultrasonic sensor pins for PikaBot is:
- TRIG - 5
- ECHO - 4
Change the pin values if you are NOT using default pins as mention in PikaBot manual.
Drag forever
and if else
block from Control
category and drop as shown below.
Drag ' '< '50'
block from Operator
category and drop it in if else
block.
Drag ultrasonic distance (cm)
from Sensors
category and drop it in ' '< '50'.
Drag move forward
and brake
blocks from Motor
category and drop it as below.
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.
MORE PROGRAMMING
Program the blocks as shown below
PikaBot comes with a push button. Default pin for the push button is pin 2.
- Press the push button to start the PikaBot to detect object
- PikaBot moves forward if the obstacle is more than 15cm
- PikaBot brakes if the is an obstacle less than 15cm
Comments