Approved content
The content below is provided by a partner.
Gcube is a cube type module which include stepper motor, battery, sensors and BLE 5.0 cpu based board. It is available to use dot-matrix, RC servo motor or various sensors with Gcube, because Gcube has general external sensor port. With just 1 Gcube you are able to make robotics and more and more Gcubes you have, you can build any kind of robot. We’ve released this extension for microbit users to use Gcube for robotics and IoT projects.
More information: www.roborisen.com qna@roborisen.com
[Manual-microbit-Gcube/PingPong] https://drive.google.com/file/d/1Cx2xfd_jyGv8ZZpOsOfL8Q2vWVdp0YYe
[Manual-microbit-Gcube/test.ts] https://drive.google.com/file/d/1KvSzr9H3UgrDJRcgs3GJok3t5EzW4rfu
[Movie-microbit-Gcube/PingPong] https://drive.google.com/file/d/1Nlr_0LPiVet9XcCz7VrC1GY5_dgytKP2
[Material-Gcube/PingPong] https://drive.google.com/drive/folders/1fqJUBc3_YiFQwCtpSOFDAteLwlszzoH4
[Movie-Gcube/PingPong] https://youtu.be/wTfnsPbgm3s
(for dot-matrix application, you should attach dot matrix to Gcube in advance)
gcube.waitFirstGcubeConnect(): void
This block is to wait until the first Gcube is connected to microbit (microbit is monitoring Gcube is turned on via serial data)
gcube.waitAllGcubesConnect(cnumber: number): void
This block is to wait until # (user define the Gcube number for their project) Gcubes are connected
gcube.setAGcubeSpeed(cubeIndex: number, motorSpeed: number): void
This block is set motor speed to # (-100~100, 100 is maximum speed i.e. 30rpm) of the Gcube #
gcube.setAllGcubeSpeed(s7: number, s6: number, s5: number, s4: number, s3: number, s2: number, s1: number, s0: number): void
This block is set all Gcube motor speed with the 8 argument numbers from Gcube 7 to Gcube 0
gcube.stopAllGcubeMotor(): void
This block is stop all of the Gcube motors
gcube.setAGcubeRotationAngle(cubeIndex: number, rotationAngle: number): void
This block is to set rotation angle to # (-10000 ~ 10000 in degrees) of the Gcube #
gcube.setAllGcubeRotationAngle(r7: number, r6: number, r5: number, r4: number, r3: number, r2: number, r1: number, r0: number): void : void
This block is to set each Gcube’s rotation angle with the 8 argument numbers from Gcube 7 to Gcube 0
gcube.setAGcubeServoAngle(cubeIndex: number, servoAngle: number): void
This block is to set servo motor angle to # (-10000 ~ 10000 in degrees) of the Gcube #
gcube.setAllGcubeServoMotorAngle(a7: number, a6: number, a5: number, a4: number, a3: number, a2: number, a1: number, a0: number): void
This block is to set each Gcube’s servo motor rotation angle with the 8 argument numbers from Gcube 7 to Gcube 0
gcube.setMatrixDisplay(cn: number, t1: string, t2: string, t3: string, t4: string, t5: string, t6: string, t7: string, t8: string): void
This block is to set 8x8 dot-matrix image of the Gcube #
gcube.defaultRollingMatrixImage(t1: string, t2: string, t3: string, t4: string, t5: string, t6: string, t7: string, t8: string): void
This block is to set default rolling 8x8 dot-matrix image with the 8 row image data
gcube.startRollingMatrixImage(duration: number): void
This block is to start rolling 8x8 dot-matrix image from Gcube 0 ~ Gcube n for # seconds
startShiftingMatrixImage(cubeIndex: number): void
This block is to start shifting 8x8 dot-matrix image from Gcube 0 ~ Gcube n for # seconds Shifting direction is depends on the acceleration sensor data of microbit
gcube.waitFirstGcubeConnect()
gcube.waitAllGcubesConnect(3)
input.onButtonPressed(Button.A, function () {
gcube.defaultRollingMatrixImage(
":",
"__0__0__0__0__0__0__0__0__",
"__0__0__0__0__0__0__0__0__",
"__0__0__0__1__1__0__0__0__",
"__0__0__1__1__1__1__0__0__",
"__0__0__1__1__1__1__0__0__",
"__0__0__0__1__1__0__0__0__",
"__0__0__0__0__0__0__0__0__",
"__0__0__0__0__0__0__0__0__"
)
})
input.onButtonPressed(Button.B, function () {
gcube.startRollingMatrixImage(1000)
})
gcube.waitFirstGcubeConnect()
gcube.waitAllGcubesConnect(3)
input.onButtonPressed(Button.A, function () {
gcube.setMatrixDisplay(
1,
"__0__0__0__0__0__0__0__0__",
"__0__0__0__0__0__0__0__0__",
"__0__0__0__1__1__0__0__0__",
"__0__0__1__0__0__1__0__0__",
"__0__0__1__0__0__1__0__0__",
"__0__0__0__1__1__0__0__0__",
"__0__0__0__0__0__0__0__0__",
"__0__0__0__0__0__0__0__0__"
)
})
gcube.waitFirstGcubeConnect()
gcube.waitAllGcubesConnect(3)
input.onButtonPressed(Button.A, function () {
gcube.setAGcubeSpeed(1, 100)
gcube.setAGcubeSpeed(2, 100)
})
input.onButtonPressed(Button.B, function () {
gcube.stopAllGcubeMotor()
})
gcube.waitFirstGcubeConnect()
gcube.waitAllGcubesConnect(3)
input.onButtonPressed(Button.A, function () {
gcube.setAGcubeRotationAngle(0, 180)
gcube.setAGcubeRotationAngle(1, 180)
gcube.setAGcubeRotationAngle(2, 180)
})
input.onButtonPressed(Button.B, function () {
gcube.setAGcubeRotationAngle(0, -300)
gcube.setAGcubeRotationAngle(1, -300)
gcube.setAGcubeRotationAngle(2, -300)
})
gcube.waitFirstGcubeConnect()
gcube.waitAllGcubesConnect(3)
input.onButtonPressed(Button.A, function () {
gcube.setAllGcubeRotationAngle(
180,
180,
180,
0,
0,
0,
0,
0
)
})
input.onButtonPressed(Button.B, function () {
gcube.setAllGcubeRotationAngle(
-300,
-300,
-300,
0,
0,
0,
0,
0
)
})
gcube.waitFirstGcubeConnect()
gcube.waitAllGcubesConnect(3)
input.onButtonPressed(Button.A, function () {
gcube.setAGcubeServoAngle(1, 30)
})
input.onButtonPressed(Button.AB, function () {
gcube.setAGcubeServoAngle(1, 90)
gcube.setAGcubeServoAngle(2, 90)
})
input.onButtonPressed(Button.B, function () {
gcube.setAGcubeServoAngle(2, 45)
})
gcube.waitFirstGcubeConnect()
gcube.waitAllGcubesConnect(3)
input.onButtonPressed(Button.A, function () {
gcube.setAGcubeRotationAngle(2, 720)
gcube.setAGcubeSpeed(3, 50)
})
input.onGesture(Gesture.TiltLeft, function () {
gcube.setAGcubeServoAngle(2, 45)
gcube.setMatrixDisplay(
3,
"__0__0__0__0__0__0__0__0__",
"__0__0__1__0__0__0__0__0__",
"__0__1__1__0__0__0__0__0__",
"__1__1__1__1__1__1__1__1__",
"__1__1__1__1__1__1__1__1__",
"__0__1__1__0__0__0__0__0__",
"__0__0__1__0__0__0__0__0__",
"__0__0__0__0__0__0__0__0__"
)
})
input.onButtonPressed(Button.AB, function () {
gcube.stopAllGcubeMotor()
})
input.onButtonPressed(Button.B, function () {
gcube.setAGcubeRotationAngle(2, -720)
gcube.setAGcubeSpeed(3, -50)
})
input.onGesture(Gesture.TiltRight, function () {
gcube.setAGcubeServoAngle(2, 135)
gcube.setMatrixDisplay(
3,
"__0__0__0__0__0__0__0__0__",
"__0__0__0__0__0__1__0__0__",
"__0__0__0__0__0__1__1__0__",
"__1__1__1__1__1__1__1__1__",
"__1__1__1__1__1__1__1__1__",
"__0__0__0__0__0__1__1__0__",
"__0__0__0__0__0__1__0__0__",
"__0__0__0__0__0__0__0__0__"
)
})
gcube.waitFirstGcubeConnect()
gcube.waitAllGcubesConnect(4)
basic.forever(function () {
if (gcube.readInternalCubeSensor(3, gcube.InternalSensor.ProximitySensor) < 200) {
gcube.rotateWheelRobot(gcube.RobotName.AutoCar, gcube.readCubeAccelerometer(3, gcube.CubeAccelerometer.Xdata))
gcube.moveWheelRobot(gcube.RobotName.AutoCar, gcube.readCubeAccelerometer(3, gcube.CubeAccelerometer.Ydata) / 3)
}
})
This example shows
[Preparation & connection]
* Description: Sends serial data to a device referred to as "gcube."
* Parameters:
xdata (Array): An array containing data to be transmitted over serial.
* Description: Prepares and sends matrix data to a device.
* Parameters:
cn (Number): An identifier for the data.
t1, t2, t3, t4, t5, t6, t7, t8 (Number): Numeric data for the matrix.
* Description: Initiates the shifting of a matrix image on the specified gcube.
* Parameters:
cubeIndex (Number): The index of the target Gcube to display the shifting matrix image.
* Description: Starts rolling a matrix image for a specified duration.
* Parameters:
duration (Number): The duration (in seconds) for which the matrix image should roll. Use 0 for continuous rolling.
* Description: Sets the default rolling display image for the 8x8 dot matrix of gcube.
* Parameters:
dm (String): Dummy index.
t1, t2, t3, t4, t5, t6, t7, t8 (String): Image lines for the 8x8 dot matrix.
* Description: Sets the matrix image of a specific gcube.
* Parameters:
cn (Number): The index of the target gcube.
t1, t2, t3, t4, t5, t6, t7, t8 (String): Image lines for the 8x8 dot matrix.
* Description: Sets the angles of servo motors for all Gcubes.
* Parameters:
dm (String): Dummy index.
a7, a6, a5, a4, a3, a2, a1, a0 (Number): Servo motor angles for Gcubes.
* Description: Sets a Gcube's servo motor to a specific angle.
* Parameters:
cubeIndex (Number): The index of the target gcube.
servoAngle (Number): The angle (in degrees) to set the servo motor to.
* Description: Sets the rotation angles of all Gcube motors.
* Parameters:
dm (String): Dummy index.
r3, r2, r1, r0 (Number): Rotation angles (in degrees) for Cube 3 or 7, Cube 2 or 6, Cube 1 or 5, and Cube 0 or 4, respectively.
* Description: Sets a Gcube's motor to a specific rotation angle.
* Parameters:
cubeIndex (Number): The index of the target gcube.
rotationAngle (Number): The rotation angle in degrees, in the range of -1000 to 1000.
* Description: Stops all Gcube motors.
* Parameters: None.
* Description: Sets the speeds of all Gcube motors.
* Parameters:
dm (String): Dummy index.
s7, s6, s5, s4, s3, s2, s1, s0 (Number): Speed values for Cube 7, Cube 6, Cube 5, Cube 4, Cube 3, Cube 2, Cube 1, and Cube 0, respectively.
* Description: Sets a Gcube's motor to a specific speed.
* Parameters:
cubeIndex (Number): The index of the target gcube.
motorSpeed (Number): The motor speed value.
* Description: Waits for a specified number of Gcubes to be connected before proceeding with the user's project.
* Parameters:
cnumber (Number): The desired number of Gcubes to wait until.
* Description: Waits for the first Gcube to be connected before proceeding with the user's project.
* Parameters: None.
gcube=github:roborisen/gcube#v1.2.66