For the former, a MOSFET can be used as a switch. Below is a simple example I'll show the kids next wee: a motor powered by a separate power supply that is shut on an off by sending highs and low from an Arduino digital out pine to the gate of the MOSFET. Signal high, MOSFET switches motor on. Signal low, motor is off.
·
The diode running parallel with the motor is
sometimes called a flyback or kickback diode.
When current is shut off in a device that has a coil, like a motor or a
relay, some of it will run backwards, which can possibly blow the MOSFET. The diode routs that backwards current back
to the motor, protecting the MOSFET.
·
The 10k resistor we see often in Arduino sketches. It functions a pulldown
resistor. It keeps the gate voltage at 0
if the Arduino output is low. This
avoids what is called a floating pin
situation. We don’t want any stray voltage to the gate except when we signal it
to be there with the digital out.
a And here's the generic code, setting the motor to go on and off at 5 second intervals.
int motor=3;
void setup ()
{
pinMode (motor,
OUTPUT);
}
void loop ()
{
digitalWrite (motor,
HIGH);
delay (5000);
digitalWrite (motor,
LOW);
delay (5000);
}
If things work out, we can shut off the Vernier shield at much longer intervals, saving valuable milliamps along the way.
No comments:
Post a Comment