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 third lesson (linefollow) 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 | 2 Detect Object
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 hereto learn how to use Motors for PikaBot.
Initialize the line sensors by drag initialize line sensor:..
block from Sensors
category and drop it under initialize left motor...
Default line sensor pins for PikaBot is:
- Left IR - A0
- Right IR - A1
Change the pin values if you are NOT using default pins as mention in PikaBot manual.
Drag forever
,if
and if else
block from Control
category and drop as shown below.
Drag ' ' and ' '
block from Operator
category and drop it in first if else
block.
Drag not ' '
block from Operator
category and drop it in ' ' and ' '
block.
Drag left IR detects dark
block from Sensors
category and drop it in not ' '
and if else
block. Change left IR detects dark
to right IR detects dark
using the dropdown on the block.
Drag move forward
, turn left
and turn right
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.
TESTING
MORE PROGRAMMING
This program combines all the PikaBot lessons taught in this series.
- Press the push button to start the PikaBot to follow the line
- PikaBot brakes if the is an obstacle less than 15cm
- PikaBot starts line follow if the obstacle is more than 15cm
- PikaBot moves forward when both line sensors detects bright
- PikaBot turns left when left line sensor detects dark
- PikaBot turns right when right line sensor detects dark
Comments
Please log in or sign up to comment.