This is the simplest motor driver that could possibly be built using only one NPN transistor, which is controlled and driven by the ESP32 micro controller board.
Choose ESP32 as the board under tools, and plug it in. Choose the corresponding USB port that is labeled ESP32, then upload the following code to the board.
const int motorPin = 5;
void setup() { //set motorPin as OUTPUT pinMode(motorPin, OUTPUT); }
void loop() {
motorOnThenOff();
}
// This function turns the motor on and off like the blinking LED. // Try different values to affect the timing. void motorOnThenOff() { // milliseconds to turn the motor on int onTime = 3000; // milliseconds to turn the motor off int offTime = 3000;
// turn the motor on (full speed) digitalWrite(motorPin, HIGH); // delay for onTime milliseconds delay(onTime); // turn the motor off digitalWrite(motorPin, LOW); // delay for offTime milliseconds delay(offTime); }