High Speed DC Toy Motor with Fan (2pcs) Documentation
The High Speed DC Toy Motor with Fan is a compact, high-performance motor designed for various IoT projects and applications. It features a built-in fan for cooling and is suitable for use in robotics, drones, and other small-scale systems. This documentation provides a comprehensive guide on how to use this component, including code examples in different programming languages.
Operating Voltage: 3-6V DC
Rated Current: 100-150mA
Speed: 10000-12000 RPM
Fan Size: 20mm x 20mm x 10mm
Motor Size: 27mm x 12mm x 15mm
Weight: 20g (each motor)
The motor has three pins:
VCC (Red): Positive power supply pin
GND (Black): Ground pin
Signal (Yellow): Control signal pin (PWMed for speed control)
### Example 1: Arduino - Simple Motor Control
In this example, we will demonstrate how to control the motor speed using an Arduino board.
Arduino Uno or compatible board
High Speed DC Toy Motor with Fan (2pcs)
Breadboard and jumper wires
Code
```c
const int motorPin = 9; // Signal pin connected to digital pin 9
void setup() {
pinMode(motorPin, OUTPUT);
}
void loop() {
// Set motor speed to 50% (12000 RPM / 2)
analogWrite(motorPin, 128);
delay(1000);
// Set motor speed to 25% (6000 RPM / 2)
analogWrite(motorPin, 64);
delay(1000);
// Stop the motor
analogWrite(motorPin, 0);
delay(1000);
}
```
### Example 2: Raspberry Pi (Python) - Motor Control with PWM
In this example, we will demonstrate how to control the motor speed using a Raspberry Pi and Python.
Raspberry Pi 3 or compatible board
High Speed DC Toy Motor with Fan (2pcs)
Breadboard and jumper wires
Code
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
motor_pin = 18 # Signal pin connected to GPIO 18
GPIO.setup(motor_pin, GPIO.OUT)
pwm = GPIO.PWM(motor_pin, 50) # 50 Hz PWM frequency
while True:
# Set motor speed to 50% (12000 RPM / 2)
pwm.start(50)
time.sleep(1)
# Set motor speed to 25% (6000 RPM / 2)
pwm.start(25)
time.sleep(1)
# Stop the motor
pwm.stop()
time.sleep(1)
```
### Example 3: ESP32 (MicroPython) - Motor Control with PWM
In this example, we will demonstrate how to control the motor speed using an ESP32 board and MicroPython.
ESP32 DevKitC or compatible board
High Speed DC Toy Motor with Fan (2pcs)
Breadboard and jumper wires
Code
```python
import machine
import time
motor_pin = machine.Pin(18, machine.Pin.OUT) # Signal pin connected to GPIO 18
pwm = machine.PWM(motor_pin, freq=50) # 50 Hz PWM frequency
while True:
# Set motor speed to 50% (12000 RPM / 2)
pwm.duty(512) # 10-bit PWM resolution (0-1023)
time.sleep(1)
# Set motor speed to 25% (6000 RPM / 2)
pwm.duty(256)
time.sleep(1)
# Stop the motor
pwm.duty(0)
time.sleep(1)
```
Note: In the above examples, the motor speed is controlled using PWM (Pulse Width Modulation). The duty cycle of the PWM signal determines the motor speed. A higher duty cycle results in a higher motor speed.