You can't control motors directly from your BrainBlock;
you need a DriverBlock to connect your GoBlocks to your BrainBlock.
This is Dual Motor Driver - it can control 2 motors at the same time.
Each motor needs 2 pins to control it.
This gives 4 possible combinations, we end up with an extra combination, so we have two combinations that both stop the motor.
D5 | D6 | Motor A | D5 | D6 |
---|---|---|---|---|
LOW | LOW | Stopped | 0 | 0 |
LOW | HIGH | Backward | 0 | 1 |
HIGH | LOW | Forward | 1 | 0 |
HIGH | HIGH | Stopped | 1 | 1 |
D9 | D10 | Motor B | D9 | D10 |
---|---|---|---|---|
LOW | LOW | Stopped | 0 | 0 |
LOW | HIGH | Backward | 0 | 1 |
HIGH | LOW | Forward | 1 | 0 |
HIGH | HIGH | Stopped | 1 | 1 |
D5 | D6 | Motor A | D5 | D6 |
---|---|---|---|---|
LOW | LOW | Stopped | 0 | 0 |
LOW | HIGH | Backward | 0 | 1 |
HIGH | LOW | Forward | 1 | 0 |
HIGH | HIGH | Stopped | 1 | 1 |
You can control the speed of the motors using PWM (Pulse Width Modulation),
but PWM only works on Pins 3, 5, 6, 9, 10, or 11
(We have chosen 5&6 and 9&10 by default)
PWM is a number out of 255. Here are a few common values:
% | 0% | 6% | 13% | 20% | 25% | 39% | 50% | 59% | 75% | 100% | % |
---|---|---|---|---|---|---|---|---|---|---|---|
PWM | 0 | 16 | 32 | 50 | 64 | 100 | 128 | 150 | 192 | 255 | PWM |
You can create your own block for each motor
Speed is a number between -100 and 100
-100 is 100% speed backward
100 is 100% speed forward
0 is Stopped
We need to multiple Speed by 2.55 (100 x 2.55 = 255) to scale it so it works with a percent (0-100)