Overview
Use Motor module and Motion module to make an emoticon whose motor is controlled to spin through leaning the platform left and right.
Module List
Module
Other Equipment
- USB cable*1
- Lego or other fixation structures
Module Setup
Setup
- Assemble modules and sensors together:
- Connect two motors to Motor module;
- Stick the red core, yellow motion module and green motor module to the yellow battery base;
- Plug one end of USB cable into the battery base and connect the other end to computer.
Programming
Required Program Blocks
Start to Program
Motor begin
Motion DMP solution
Variable X is for storing the pitch motion degree
Constrain X to -20~20
Map X from -20~20 to -255~255
Send X to the serial monitor
The speed of the two motor is X.
Test the result
Before power on, confirm the motion module is level, and the x axis of motion sensor leans downward, and the two eyes turn left (anticlockwise); the x axis of the motion sensor leans upward, and the two eyes turn right (clockwise).
Q: Now the two eyes turn to the same direction. How to make them turn to different directions?
A: -255~0 represent rotating back, and 255~0 represent rotating forth, just change x into –x can make it rotate reversely.
Use variable Y to storing the roll motion degree.
Constrain Y to -20~20.
Map Y from -20~20 to -255~255.
The speed of motor 1A,1B is X-Y.
The speed of motor 2A,2B is X+Y.
Technical Specification
Relative Cases
FAQ
|