Driving a MOSFET using ESP-01 - Need Help
Posted: Tue Sep 07, 2021 2:33 am
I am trying to drive a MOSFET using ESP-01 to control 12V supply. Schematic is attached. Here is my simple code -
But its not switching. What am I doing wrong? Pls help
Code: Select all
#include <ESP8266WiFi.h>
#define MOSFET 2
#define SWITCH 0
#define DEBUG True
void setup() {
pinMode(SWITCH, INPUT); // Initialize the GPIO2 pin as an output
pinMode(MOSFET, OUTPUT);
digitalWrite(MOSFET, HIGH);
}
void loop() {
digitalWrite(MOSFET,HIGH);
// put your main code here, to run repeatedly:
}
But its not switching. What am I doing wrong? Pls help