Motor
The cube has two motors, with one connected to the left wheel and one to the right wheel (see Parts). These motors can be controlled using the following characteristics.
| Property | Value |
|---|---|
| Characteristic UUID | 10B20102-5B3B-4571-9508-CF3EFCD7BBAE |
| Properties | Write without response, Read, Notify |
| Descriptor | Motor Control |
Write operations
Motor Control
The motor can be controlled by writing the following configuration data. The motors continue to run at the specified speed until the next write operation is performed.
| Data location | Type | Content | Example |
|---|---|---|---|
| 0 | UInt8 | Control type | 0x01 (Motor control) |
| 1 | UInt8 | ID of motor controlled | 0x01 (Left) |
| 2 | UInt8 | Motor rotation direction | 0x01 (Forward) |
| 3 | UInt8 | Motor speed command values | 0x64 (100) |
| 4 | UInt8 | ID motor controlled | 0x02 (Right) |
| 5 | UInt8 | Motor rotation direction | 0x02 (Backward) |
| 6 | UInt8 | Motor speed command values | 0x14 (20) |
ID motor controlled
Specifies the ID of the motor being controlled. The ID of the left motor is 1 and the ID of the right motor is 2.
As there are two locations for which motor ID are specified, if both are specified with the same ID, an error occurs and the write operation is ignored.
Motor rotation direction
Specifies the rotation direction for the motor that was just specified.
The value for moving the cube forward is 1 and the value for moving it backward is 2.
Motor speed command values
Specify the rotation speed for the motor that was just specified.
The speed of the motor can be specified with values ranging between 0 and 255. The correlation between the speed of the motor and the actual rotation speed of the wheels is shown in the graph below.
Motor control with specified duration
The duration of the operation can be specified with the control of the motors by writing the following configuration data. The motor stops after the specified time has elapsed.
| Data location | Type | Content | Example |
|---|---|---|---|
| 0 | UInt8 | Control type | 0x02 (Motor control with specified duration) |
| 1 | UInt8 | ID of motor controlled | 0x01 (Left) |
| 2 | UInt8 | Motor rotation direction | 0x01 (Forward) |
| 3 | UInt8 | Motor speed command values | 0x64 (100) |
| 4 | UInt8 | ID motor controlled | 0x02 (Right) |
| 5 | UInt8 | Motor rotation direction | 0x02 (Backward) |
| 6 | UInt8 | Motor speed command values | 0x14 (20) |
| 7 | UInt8 | Motor control duration | 0x0A (100 msec) |
Motor control duration
The duration in which the motor is controlled is specified with values ranging from 0 to 255. A value of 0 means that there is no time limit and the motor continues to run at the specified speed until the next write operation is performed. For values ranging between 1 and 255, the motor for 10 times the specified value in milliseconds, then stops.
Motor control with target specified
Motors can be controlled with a target state specified to make the cube move autonomously. Targets that can be set are made up of the following.
- X coordinate of the target point's Position ID
- Y coordinate of the target point's Position ID