ranger robot · 1 x 3-axis accelerometer and gyro sensor 1 x thermistor sensor speaker: 1 x buzzer...
Post on 04-Aug-2020
1 Views
Preview:
TRANSCRIPT
Last update August 2nd, , 2020 Page 1 of 56
MAKEBLOCK WITH ARDUINO-C
RANGER ROBOT
Samples Documentation
BY : STORMING ROBOTS
Last update August 2nd, , 2020 Page 2 of 56
MAKEBLOCK WITH ARDUINO-C
TABLE OF CONTENTS
SECTION I - STARTUP ............................................................................................................. 6
about the RangerBot .....................................................................................................................................6
Assemble it ........................................................................................................................................................7
Do’s and Don’ts: ..............................................................................................................................................7
Practice good battery Care: .........................................................................................................................8
Challenge ...........................................................................................................................................................9
SECTION II TO GET STARTED WITH THE SOFTWARE .................................................................... 10
Download mblock software ................................................................................................................... 10
Know the MBlock Interface – Divided into Panes ..................................................................10
Test out your first program. ..................................................................................................................... 13
Tips on the Converted Arduino -C code .............................................................................................. 14
SECTION III SENSING ............................................................................................................ 15
Samples for the Light Sensor ................................................................................................................... 15
Blocky Version -1 .............................................................................................................................15
Arduino-C Version -1 ......................................................................................................................16
Blocky Sample -2 ......................................................................................................................................... 17
Arduino Arduino-C Version ...........................................................................................................17
Samples for the Sound Sensor ................................................................................................................ 18
Blocky Version ....................................................................................................................................18
Arduino-C Version ............................................................................................................................18
Samples for the Accelerometer & Gyro ............................................................................................... 19
Blocky Version ....................................................................................................................................19
Arduino-C Version ............................................................................................................................20
Last update August 2nd, , 2020 Page 3 of 56
MAKEBLOCK WITH ARDUINO-C
Samples for the Thermistor ...................................................................................................................... 21
Blocky Version ....................................................................................................................................21
Arduino-C Version ............................................................................................................................21
Samples for the Line Follower ................................................................................................................. 22
Blocky Version ...................................................................................................................................22
Arduino-C Version for Sample 2 ..................................................................................................24
Samples for the Ultra sonic sensor ........................................................................................................ 25
Blocky Version – Sample1 ..............................................................................................................25
Quick Challenge: ................................................................................................................................25
Blocky Version ....................................................................................................................................25
Blocky Version – Sample 2 .............................................................................................................26
Arduino-C Version ............................................................................................................................26
Samples for the Timer ................................................................................................................................ 27
Blocky Version ....................................................................................................................................27
Challenge List .....................................................................................................................................27
SECTION IV -PROGRAMMING BUZZER & RGB RING ................................................................ 28
Samples for turning on the Buzzer ........................................................................................................ 28
Blocky Version ....................................................................................................................................28
Arduino-C Version ....................................................................................................................................... 28
Sample for RGB-LED Ring? ....................................................................................................................... 30
Test it out in Live mode... ................................................................................................................30
Blocky Version ....................................................................................................................................30
‘Arduino-C version ............................................................................................................................31
Challenge List ................................................................................................................................................ 32
SECTION V - WORK WITH MOTORS ........................................................................................ 33
Basic Motor movements ........................................................................................................................... 33
Last update August 2nd, , 2020 Page 4 of 56
MAKEBLOCK WITH ARDUINO-C
Blocky Version ....................................................................................................................................33
Arduino-C Version ............................................................................................................................33
Motor movements with ultrasonic sensor .......................................................................................... 35
Blocky Version ....................................................................................................................................35
Arduino-C Version ............................................................................................................................35
Motor movements based on rotation per minute ........................................................................... 36
Blocky Version ....................................................................................................................................36
Arduino-C Version ...........................................................................................................................36
Motor movements by the encoder value ............................................................................................ 38
Arduino-C Version ...........................................................................................................................38
Challenge List ................................................................................................................................................ 39
SECTION VI – A BIT MORE ADVANCED PROJECTS .................................................................... 40
Blink faster when it detects louder sound ........................................................................................... 40
Blocky Version ....................................................................................................................................40
Arduino-C Version ............................................................................................................................40
Sync your LEDs with sound ...................................................................................................................... 42
Blocky Version ....................................................................................................................................42
Arduino-C Version ............................................................................................................................43
Pixel RGB Ring Disco .................................................................................................................................. 44
Blocky Version ....................................................................................................................................44
Arduino-C Version ............................................................................................................................44
Movements with encoder measurement ............................................................................................. 46
Activate the PIXEL-RGB RING based on Gyro reading. ........................................................47
Line following with feedack control ...................................................................................................... 48
Get around a known size obstacle with Math ................................................................................... 49
Advanced Dot Matrix Display – Text Scrolling ................................................................................... 50
Last update August 2nd, , 2020 Page 5 of 56
MAKEBLOCK WITH ARDUINO-C
Blocky Version ....................................................................................................................................50
Arduino-C Version ............................................................................................................................50
SECTION VII - APPENDIX ...................................................................................................... 51
What do the colors on the ports mean? .............................................................................................. 51
How to add on additional sensing in the future? ............................................................................. 53
Bug - The 12 RGB LEDs on Ranger ........................................................................................................ 53
Creating your own Scratch Extension ................................................................................................... 53
External Reference: ...........................................................................................................................56
Last update August 2nd, , 2020 Page 6 of 56
MAKEBLOCK WITH ARDUINO-C
Section I - STARTUP Next ➢
ABOUT THE RANGERBOT
The main controller board Me Auriga
Based on open-source Arduino. Arduino Mega 2560, 256 KB
flash memory, 8 KG SRAM, 4KB EEPROM.
Hardware Serial port. (can
be connected with
Bluetooth module )
Two encoder motor ports
NeoPixels Ring.
(ref: Adafruit)
This power switch is for the
motor!
Buzzer
These 2 light
sensors to test
ambient light.
Go here to view
what the color
codes mean.
Motor Expansion ports
Sound Sensor
Last update August 2nd, , 2020 Page 7 of 56
MAKEBLOCK WITH ARDUINO-C
LIST :
On-board Sensors/devices
2 x Light sensor
1 x Sound sensor
1 x 3-Axis Accelerometer and Gyro Sensor
1 x Thermistor sensor
Speaker: 1 x Buzzer
12-RGB LED
Wireless Communication: Bluetooth
Sensor modules:
1 x Line follower reflective sensor
1 x Ultrasonic sensor
Motors:
2 x Encoder Motors : 400 RPM . Torque:?
Software and programming: PC-mBlock; iPad/Tablet-Makeblock and Arduino IDE
The Bluetooth module in this kit enables you to connect Ranger with smartphones, tablets or
computers. You can also add a 2.4G module to the Hardware Serial port.
ASSEMBLE IT
Here is a modified building instruction for the Ranger Bot. You may refer back to the manual or the paper manual from the
box.
Do not forget that you will need six 1.5V AA batteries.
DO’S AND DON’TS:
⎯ Do Not push or pull the motor wires.
⎯ Do not swing your robot by using motors as the handler.
⎯ Watch out for low battery indicators:
o If the robot moves very slowly, automatically restarts while turning, bumps into thing or doesn’t move at all
despite the motor speed being set to full power, the batteries are low. If the robot easily loses its balance while
moving or turning, the batteries are low. You should change batteries when any of these symptoms happens.
⎯ Changing batteries? Power down the robot and replace or charge the batteries.
Last update August 2nd, , 2020 Page 8 of 56
MAKEBLOCK WITH ARDUINO-C
PRACTICE GOOD BATTERY CARE:
1 - Use only fresh batteries of AA batteries.
2 - Should always remove batteries if the robot is not in used for some time.
3 - Do not mix old and new batteries, nor different types of batteries, e.g. all alkaline or al rechargeable, etc.
4 - May use either 1.2V (6) AA rechargeable batteries, or 1.5V (6) AA alkaline battery, but use good quality batteries such
as Energizer, Duracell.
5 - Replace all batteries of the same type/brand at the same time.
6 - The positive and negative connection must be correct.
Last update August 2nd, , 2020 Page 9 of 56
MAKEBLOCK WITH ARDUINO-C
CHALLENGE
- Name the Mechanical Parts of mBot Ranger Robot Kit .
Last update August 2nd, , 2020 Page 10 of 56
MAKEBLOCK WITH ARDUINO-C
Section II TO GET STARTED WITH THE SOFTWARE Prev Next ➢
DOWNLOAD MBLOCK SOFTWARE
Know the MBlock Interface – Divided into Panes
The screen is divided into multiple sections or "panes" categorized with have different functionalities.
These panels are very self-explanatory. However, I think the the following needs to be emphasized.
Others
the MBlock IDE ( Integrated
Development Environment)
Script Area The scripts area is the work pad where
your code is dragged from Block Palette
to and assembled.
Blo
ck
T
yp
es
Ad
d D
ev
ices
Staging Area
Running
Mode
Menu Bar
P.E.
Staging
Control
Mode
Control
Block Palette
Switch between Arduino-C and
MBlock
Last update August 2nd, , 2020 Page 11 of 56
MAKEBLOCK WITH ARDUINO-C
STAGING AREA & CONTROL
This is an area where you may show variables or sensors values while running your program. This can be extremely useful for
testing data range of a sensor or testing while in Live mode. (see below).
E.g. you have created a variable called “loud”. Once you check the box, it will show up at the Staging area.
Control allows to resize the staging area.
ADD DEVICE AND P.E. (PLATFORM EXTENSION)
1) Add the Ranger Device:
2) Add Extension: the Maker’s Platform
BLOCK TYPES, PALETTE AND SCRIPT AREA
⎯ Block Types: programming commands/expressions Categories
⎯ Script Areas: your programming area.
***Afterwards, you
should keep Ranger
selected at all times.
Last update August 2nd, , 2020 Page 12 of 56
MAKEBLOCK WITH ARDUINO-C
RUNNING MODE - LIVE VS UPLOAD***
Live : Running your code directly connected to the robot. This takes round trip communication; thus the execution will take
much longer than upload. However, it is a convenient way for testing, debugging and analysis when constant close observation
is necessary. To
1) To enable “Live” mode :
In the Running mode pane:
2)To find the start up command
block:
In Block Type Pane
3)To add in the startup block
In Block Palette Pane
While you may use others, this is
used throughout this document.
4)To run it in Live mode:
Pop up window:
5)shortcut icons for start and stop Live
mode:
Upload : Your code will be compiled into a format that your robot can understand, and downloaded into the robot brain.
This allows your robot to run by itself.
1)To enable “Upload” mode :
In the Running mode pane:
then
2)To find the startup command block:
In Block Type Pane
3)To add in the startup block
In Block Palette Pane
4)To run it:
Pop up window:
Last update August 2nd, , 2020 Page 13 of 56
MAKEBLOCK WITH ARDUINO-C
IMPORTANT NOTE ABOUT SWITCHING BETWEEN LIVE AND UPLOAD MODE
⎯ Possible failure to reconnect in Live Mode after working in Upload Mode:
o May need to reconnect, or re-update the firmware.
⎯ If you see this, the chance is that you will need to re-update the firmware.
OTHER BASIC OPERATIONS THAT YOU SHOULD BE FAMILIAR WITH :
1 - insert/move/delete a single block vs. a set of blocks.
2 - How to insert/move/delete a set of blocks
3 - How to insert/delete comment
4 - How to create “myBlock” (for more advanced user)
TEST OUT YOUR FIRST PROGRAM.
Best way to learn this it to do a very simple sample:
Step 1: Sample : Play a note with one second pause in-between. Do this forever.
Step 2: Test it in live mode, and click on to test – robot should start buzzing.
Click on to stop.
Step 3: Switch to upload mode. Don’t forget to replace the first block with
this: Upload and Connect. Robot starts buzzing again.
Step 4: (Optional) Test it out with the Arduino -C code.
1 - get a copy of the converted C code by clicking on .
do note that this section is “readonly”.
2 - When the pane filled with C code shows up, copy the whole C program.
3 - Click on Arduino-C Tab.
4 - Paste your code in.
5 - Now you can make modification if you wish.
6 - Upload the code. If you have errors in your code, you will get error message.
!
Last update August 2nd, , 2020 Page 14 of 56
MAKEBLOCK WITH ARDUINO-C
Automatically generated: To Simplify:
TIPS ON THE CONVERTED ARDUINO -C CODE
1 - You will need to be in “Upload Mode”.
2 - Since this is converted from the Blocky code, it is inevitable to have some template code embedded into the C code.
3 - While the converted code will still work as how it has worked in Blocky.
4 - However, if you do wish to eventually switch to Arduino-C, you should proceed with some cleanup, such as removing
some template codes that do not belong. See the following converted as an example.
5 - Select Mega or Mega 2560 as the controller board in Arduino.
#include <Arduino.h>
#include <MeAuriga.h>
Must include these header files by default.
#include <Wire.h>
#include <SoftwareSerial.h>
These are needed in only some cases. For this sample,
it is not needed.
MeBuzzer buzzer;
Create a variable for the embedded buzzer device.
MeLightSensor lightsensor_12(12);
float on = 0; Useless statements for this sample. Delete them.
void _delay(float seconds) {
if(seconds < 0.0){
seconds = 0.0;
}
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}
*** Should keep this Version of delay( .. ) as default,
when working with motor movements with encoder.
May remove for this sample.
Otherwise, you may use the native delay(.. ) API from
Arduino-C.
void setup() {
buzzer.setpin(45);
randomSeed((unsigned long)
(lightsensor_12.read() * 123456));
while(1) {
buzzer.tone(262, 0.25 * 1000);
_delay(0.02);
_delay(1);
_loop();
}
}
void _loop() {
}
void loop() {
_loop();
}
You should follow Arduino vernacular:
Setup( ) should not have an infinite loop.
All codes which need to loop forever should not
moved to loop( ). Replace the section with the
following codes:
void setup() {
buzzer.setpin(45);
}
void loop() {
buzzer.tone(262, 0.25 * 1000);
delay(1);
}
Modify this
section – see
sample on the
right.
Last update August 2nd, , 2020 Page 15 of 56
MAKEBLOCK WITH ARDUINO-C
Section III SENSING Prev Next ➢
Brightness sensor value
SAMPLES FOR THE LIGHT SENSOR
Best is to do this in Live Mode to start.
Blocky Version -1
1) Create variables ”see”
Make sure you will click on the checkboxes. This
will allow you to view the values in the Stage
Pane.
2) Write your code
Change to larger readout: right click on :
Observe the values, especially the maximum and
minimum.
The number won’t update!?
- Check your code to ensure you did have the variables created, and set to the proper sensor.
- If you do not see the display update, you may need to stop it, reconnect, start again.
Click one of these 3 controls to
change the Stage viewing size.
2 Light Sensors
Click here to start and stop.
Last update August 2nd, , 2020 Page 16 of 56
MAKEBLOCK WITH ARDUINO-C
Arduino-C Version -1
1) Switch to Upload Mode.
2) Get the converted C code .
⎯
3) Copy the code, then code that window by
4) Open the Arduino window and paste the code in .
5) (Optional) Simplify the code, add in display code, and run it in the Arduino IDE.
6) Make sure you “Disconnect” the robot from the Blocky Environment befroe you try to have Arduino IDE communicated
with the robot.
Last update August 2nd, , 2020 Page 17 of 56
MAKEBLOCK WITH ARDUINO-C
BLOCKY SAMPLE -2
Let’s work in Upload Mode.
Arduino Arduino-C Version
Last update August 2nd, , 2020 Page 18 of 56
MAKEBLOCK WITH ARDUINO-C
SAMPLES FOR THE SOUND SENSOR
Best is to do this in Live Mode.
Blocky Version
Let’s do this in Live Mode.
1) Create variables ”loud”
Make sure you will click on the checkboxes. This
will allow you to view the values in the Stage
Pane.
2) Write your code
Arduino-C Version
Click here to enlarge the
Stage viewing window.
3) Click here to start and
stop.
Last update August 2nd, , 2020 Page 19 of 56
MAKEBLOCK WITH ARDUINO-C
SAMPLES FOR THE ACCELEROMETER & GYRO
Measures the angular rate and the acceleration
This is a MPU-6050 based gyro sensor which combines a 3-axis
gyroscope, accelerometer, and a Digital Motion Processor (DMP)
capable of processing complex 9-axis Motion Fusion algorithms.
Blocky Version
Let’s do this in Live Mode.
CREATE VARIABLES X, Y, Z
Make sure you will click on the checkboxes. This will allow you to view the values in the Stage Pane.
WRITE YOUR CODE
You will need to select the Newly added Makers Platform.
Click here to enlarge the
Stage viewing window.
Click here to start and
stop.
From MakeBlock
Last update August 2nd, , 2020 Page 20 of 56
MAKEBLOCK WITH ARDUINO-C
Arduino-C Version
Last update August 2nd, , 2020 Page 21 of 56
MAKEBLOCK WITH ARDUINO-C
SAMPLES FOR THE THERMISTOR
This is a tiny thermometer (a NTC thermistor), where
NTC = Negative Temperature Coefficient
the resistance temperature.
Range: unknown . You should test it based your environment.
Blocky Version
Let’s do this in Upload Mode.
Arduino-C Version
From MakeBlock
Last update August 2nd, , 2020 Page 22 of 56
MAKEBLOCK WITH ARDUINO-C
SAMPLES FOR THE LINE FOLLOWER
Blocky Version
Let’s do this in Live Mode.
Observe the values you got back from the Line Following sensor.
SAMPLE 1:
Note :
Only “See “ will change because
other variables are not being
changed.
Very straight forward and simple
make-shift line tracing.
Possible problem:
- when left and right see
black, the robot will just
stop and never proceed.
Last update August 2nd, , 2020 Page 23 of 56
MAKEBLOCK WITH ARDUINO-C
SAMPLE 2:
Others such as the following are not optimal to use because it will stop the motor after the specified time expired. If you wish
to have the motor continuously running, you should not use these blocks. There are options that you can explore in the
Makers platform. This will be covered in the Motor section later in this article.
Another make-shift sample uses the
possible values from the sensors:
3 = both see white
2 = only left sees white
1 = only right sees white
0 = both see black.
This has the same issue:
- when left and right see
black, the robot will just
stop and never proceed.
Last update August 2nd, , 2020 Page 24 of 56
MAKEBLOCK WITH ARDUINO-C
Arduino-C Version for Sample 2
This is to initialize the motors. This will be discussed further
in more advanced level. But for the time being, you must
have these included in your program in order to work with
motors.
All Encoder_X references are specific to motors only.
Last update August 2nd, , 2020 Page 25 of 56
MAKEBLOCK WITH ARDUINO-C
SAMPLES FOR THE ULTRA SONIC SENSOR
Range: approximate 3cm to 400cm
Viewing Angle : 30 degrees angle
Blocky Version – Sample1
Let’s do this in LIve Mode.
Quick Challenge:
Write a Viewing program to probe the ultrasonic sensor to test the minimum and maximum range for the ultrasonic sensor
you have.. Make sure you use a flat solid surface, such as a piece of paper, do not use a cylindrical object, nor objects that
absorbs sound, such as cotton, carpet, etc.
Blocky Version
From MakeBlock
Last update August 2nd, , 2020 Page 26 of 56
MAKEBLOCK WITH ARDUINO-C
Blocky Version – Sample 2
Arduino-C Version
Last update August 2nd, , 2020 Page 27 of 56
MAKEBLOCK WITH ARDUINO-C
SAMPLES FOR THE TIMER
Timer works like a timer watch, goes as a float number type with 0.001 second increment
Blocky Version
Let’s do this in LIve Mode.
1) Create variables ”loud”
Make sure you will click on the checkboxes. This will allow you to view the
values in the Stage Pane.
2) Write your code
Challenge List
To be Updated...
Click here to enlarge the
Stage viewing window.
Click here here to start and
stop.
Last update August 2nd, , 2020 Page 28 of 56
MAKEBLOCK WITH ARDUINO-C
Section IV -PROGRAMMING BUZZER & RGB RING Prev Next ➢
SAMPLES FOR TURNING ON THE BUZZER
Let’s do this in Upload Mode.
Blocky Version
Let’s do this in Upload Mode.
ARDUINO-C VERSION
Divide and Conquer! Try the following first before you start typing a lot of them.
After you have tested this, complete the rest. Sample next page:.
Last update August 2nd, , 2020 Page 29 of 56
MAKEBLOCK WITH ARDUINO-C
(For the Buzzer Sample)
Last update August 2nd, , 2020 Page 30 of 56
MAKEBLOCK WITH ARDUINO-C
SAMPLE FOR RGB-LED RING?
Test it out in Live mode...
Let’s do this in LIve Mode. (to be updated...)
1) Create variables ”rgbValue”
Make sure you will click on the checkboxes. This will
allow you to view the values in the Stage Pane.
2) Write your code
See the value in the Stage area:
Blocky Version
Click here to enlarge the
Stage viewing window.
Click here to start and
stop.
Last update August 2nd, , 2020 Page 31 of 56
MAKEBLOCK WITH ARDUINO-C
‘Arduino-C version
ALTERNATIVE LOOP( )
Last update August 2nd, , 2020 Page 32 of 56
MAKEBLOCK WITH ARDUINO-C
CHALLENGE LIST
To be updated
Last update August 2nd, , 2020 Page 33 of 56
MAKEBLOCK WITH ARDUINO-C
Section V - WORK WITH MOTORS Prev Next ➢
BASIC MOTOR MOVEMENTS
Blocky Version
Arduino-C Version
Special note: The converted Arduino-C codes directly from MakeBlock is “very poorly” written and hard to read. The
following is a much improved version.
Header and you must instantiate motor objects first:
Initialize the motors. The following must be done before using motors:
Last update August 2nd, , 2020 Page 34 of 56
MAKEBLOCK WITH ARDUINO-C
The MeEncoderOnBoard DEMANDS that the motor loop functions NEVER BE BLOCKED (they need to always be called).
Thus, although it seems odd to write our own delay but it is required. * See the MakeBlock’s note online regarding this
restriction.
A simple function to do speed conversion 0 to 255 to 0 to 100:
The setup( ) and loop( ) in Arduino:
Last update August 2nd, , 2020 Page 35 of 56
MAKEBLOCK WITH ARDUINO-C
MOTOR MOVEMENTS WITH ULTRASONIC SENSOR
Blocky Version
Arduino-C Version
speedval( .. ) and setup( ) functions go here.
Last update August 2nd, , 2020 Page 36 of 56
MAKEBLOCK WITH ARDUINO-C
MOTOR MOVEMENTS BASED ON ROTATION PER MINUTE
Blocky Version
Arduino-C Version
Let’s take a look one section at a time:
1) Insert your header and motors variables, etc.
2) Put in _delay( ... ) function
3) Insert 2 motor interrupt functions as below:
Last update August 2nd, , 2020 Page 37 of 56
MAKEBLOCK WITH ARDUINO-C
4) Complete the setup( ) function with codes below:
void setup( ) {
a. Need to attach an Interrupt function to the right motor.
b. Need to attach an Interrupt function to the right motor.
c. Start running the motors:
Last update August 2nd, , 2020 Page 38 of 56
MAKEBLOCK WITH ARDUINO-C
d. Add the following to end the setup( ) function:
5) Complete loop( ) function as below:
MOTOR MOVEMENTS BY THE ENCODER VALUE
Arduino-C Version
It is almost the same as the sample above with RPM, except:
Replace (c) and (d) with the following:
Last update August 2nd, , 2020 Page 39 of 56
MAKEBLOCK WITH ARDUINO-C
CHALLENGE LIST
To be updated..
Last update August 2nd, , 2020 Page 40 of 56
MAKEBLOCK WITH ARDUINO-C
Section VI – A BIT MORE ADVANCED PROJECTS Prev Next ➢
BLINK FASTER WHEN IT DETECTS LOUDER SOUND
Blocky Version
Arduino-C Version
Last update August 2nd, , 2020 Page 41 of 56
MAKEBLOCK WITH ARDUINO-C
Last update August 2nd, , 2020 Page 42 of 56
MAKEBLOCK WITH ARDUINO-C
SYNC YOUR LEDS WITH SOUND
Blocky Version
Last update August 2nd, , 2020 Page 43 of 56
MAKEBLOCK WITH ARDUINO-C
Arduino-C Version
Last update August 2nd, , 2020 Page 44 of 56
MAKEBLOCK WITH ARDUINO-C
PIXEL RGB RING DISCO
Blocky Version
Arduino-C Version
Last update August 2nd, , 2020 Page 45 of 56
MAKEBLOCK WITH ARDUINO-C
To be updated.
Last update August 2nd, , 2020 Page 46 of 56
MAKEBLOCK WITH ARDUINO-C
MOVEMENTS WITH ENCODER MEASUREMENT
Some of the following samples require more sophisticated technique, and thus only Arduino-C Version program will be shown
only.
To be updated
Last update August 2nd, , 2020 Page 47 of 56
MAKEBLOCK WITH ARDUINO-C
Activate the PIXEL-RGB RING based on Gyro reading.
Last update August 2nd, , 2020 Page 48 of 56
MAKEBLOCK WITH ARDUINO-C
LINE FOLLOWING WITH FEEDACK CONTROL
TO BE UPDATED
Last update August 2nd, , 2020 Page 49 of 56
MAKEBLOCK WITH ARDUINO-C
GET AROUND A KNOWN SIZE OBSTACLE WITH MATH
TO BE UPDATED
Last update August 2nd, , 2020 Page 50 of 56
MAKEBLOCK WITH ARDUINO-C
ADVANCED DOT MATRIX DISPLAY – TEXT SCROLLING
Blocky Version
Need the 8x16 Dot Matrix Display module. (not in Ranger Kit).
Arduino-C Version
To be updated.
Last update August 2nd, , 2020 Page 51 of 56
MAKEBLOCK WITH ARDUINO-C
Section VII - APPENDIX Prev Back to Top ➢
WHAT DO THE COLORS ON THE PORTS MEAN?
Ports are color-coded to identify which type of devices can be connected:
Red
Output – 6-12V DC motor Driver
Stepper Motor Driver
Encoder Motor Driver
yellow
Single-digital port
- Constant 5V DC current
Ultrasonic Sensor
RGB LED???
Limit switch? ?
Blue
Double-digital port
- Constant 5V DC current
7-Segment Display
PIR Motion Sensor
Shurtter Cable
Line Follower
IR Receiver
Grey
Serial Port of hardware
- Constant 5V DC current
BT Modle (dual Mode)
WiFi Module
Black
Analog signal port
- Constant 5V DC current
Light Sensor
Potentiometer
Joystick
4-Button
Sound Sensor
White
I2C 3-Axis Accelerometer and Gyro Sensor
Compass
Last update August 2nd, , 2020 Page 52 of 56
MAKEBLOCK WITH ARDUINO-C
Last update August 2nd, , 2020 Page 53 of 56
MAKEBLOCK WITH ARDUINO-C
HOW TO ADD ON ADDITIONAL SENSING IN THE FUTURE?
BUG - THE 12 RGB LEDS ON RANGER
BUG: #12 fails to turn on if you pass a single RGB value. it works fine with R, G, B independently.
If turn on #0, it means all
CREATING YOUR OWN SCRATCH EXTENSION
INSTALL NODE VERSION MANAGER
Excellent reference: https://linuxize.com/post/how-to-install-yarn-on-ubuntu-18-04/
https://medium.com/@hiroyuki.osaki/how-to-develop-your-own-block-for-scratch-3-0-1b5892026421
sudo apt update
#
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs
node -–Version # min v 10.16.x
npm –Version # min v 6.9.x
INSTALL NVM (NODE VERSION MANAGER) SCRIPT
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
Last update August 2nd, , 2020 Page 54 of 56
MAKEBLOCK WITH ARDUINO-C
ls ~/.nvm
# exit and re-open your terminal
nvm –Version # min 0.34.0
INSTALL NODE JS
nvm install node
node –Version #min v12.8.1
nvm install -–lts # LTS (long term support) of nvm
nvm install 8.10.0
INSTALL NEW PACKAGE MANAGER CALLED “YARN”
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee \
/etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
ADD A NEW PROJECT
yarn init <scratch1>
# look at the package.json for configuration
# yarn add <new project >
TO UPGRADE PACKAGES (IF NECESSARY)
yarn upgrade
yarn upgrade [package_name]
yarn upgrade [package_name]@[Version_or_tag]
TO INSTALL SCRATCH PACKAGES
git clone https://github.com/LLk/scratch-vm
git clone https://github.com/LLk/scratch-gui
cd scratch-vm && yarn install && yarn link
cd scratch-gui && yarn link scratch-vm && yarn install
src
Last update August 2nd, , 2020 Page 55 of 56
MAKEBLOCK WITH ARDUINO-C
│ ├── extensions
│ │ ├── scratch3_ev3
│ │ ├── scratch3_newblocks 【★ ADDED】
│ │ │ └── index.js【★ ADDED File 1】
│ │ ├── 【OTHERS】
│ │ └── scratch3_wedo2
│ ├── extension-support
│ │ ├── argument-type.js
│ │ ├── extension-manager.js 【★★ ADDED File 2】
│ │ └── 【OTHERS】
LOOK INTO THE INDEX.JS AND EXTENSION-MANAGER.JS FILE:
{
name: 'NewBlocks',
extensionId: 'newblocks',
collaborator: 'Me',
iconURL: newBlockImage,
insetIconURL: newBlockButtonImage,
description: (
<FormattedMessage
defaultMessage="New blocks."
description="my block"
id="gui.extension.newblocks.description"
/>
),
featured: true,
disabled: false,
internetConnectionRequired: true,
bluetoothRequired: false,
helpLink: 'https://scratch.mit.edu/wedo'
}
Last update August 2nd, , 2020 Page 56 of 56
MAKEBLOCK WITH ARDUINO-C
External Reference:
1 - Factory Reset Guide
2 - MakeBlock online master hardware platforms document.
3 - Makeblock Library for Arduino.
4 - Makeblock mBot Ranger Arduino-Coding Reference
5 - Makeblock mBot Input Output Functions
< End of Document>
top related