- What is a MOSFET
- MOSFET switch vs mechanical switch
- How to use MOSFET as a switch
- Go over example using a MOSFET as a switch with Arduino
Arduino Code********************************************************************
//This example code was used on the Forcetronics YouTube Channel to demonstrate how to use
//A MOSFET as a switch. The code is open for anybody to use or modify
const int nMOS = 2; //create variable for n channel MOSFET pin
const int pMOS = 3; //create variable for p channel MOSFET pin
void setup() {
pinMode(nMOS, OUTPUT); // set pin to output
pinMode(pMOS, OUTPUT); // set pin to output
}
void loop() {
digitalWrite(nMOS, HIGH); // set n MOSFET gate to high, this will turn it on or close switch
digitalWrite(pMOS, HIGH); // set p MOSFET gate to high, this will turn it off or open switch
delay(750);
digitalWrite(nMOS, LOW); // set n MOSFET gate to low, this will turn it off or open switch
digitalWrite(pMOS, LOW); // set p MOSFET gate to low, this will turn it on or close switch
delay(750);
}
No comments:
Post a Comment