controling Power Pin with code? (on/off)

Status
Not open for further replies.

NaimaSami

New member
Hello,

I have Teensy 3.2.
I want to know if I can control the power Pins with code? I mean can i switch the power on and off on that particular pin?

For example, I want to connect a fan on Pin 26 (that is 3.6 to 6.0 volt pin) and turn it on and off for a particular condition like when temperature goes above 26C turn it on, etc. Is it possible? What command you use for powering Pin 26 On/Off (if possible).

Thanks in anticipation.
 
First you must set the pin to output via pinMode(pin, OUTPUT);
Then you can use digitalWrite(pin, HIGH) to turn it on and LOW to turn it off. However, you should NOT source power from the pin itself, the pin should be on a transistor or mosfet which controls the fan
 
@tonton81 is on the money for controlling external devices. To control the whole Teensy circuit you would have to add a device similar to the AdaFruit Push-Button-Powewer switch breakout. That device uses a push button to operate a latch and a power mosfet. The other side of the latch can be controled by a digitsl pin to turn the latch 'off'. I have also seen other latch circuits that allow touch operation to toggle the state of the latch with a short touch for 'on' and a longer touch for 'off'.
 
First you must set the pin to output via pinMode(pin, OUTPUT);
Then you can use digitalWrite(pin, HIGH) to turn it on and LOW to turn it off. However, you should NOT source power from the pin itself, the pin should be on a transistor or mosfet which controls the fan


I get it. What you mean is, don`t connect the fan directly to pin 26 right? I have a 4V mini fan that i want to automate.
 
Correct, the fan must get it's power from the mosfet or transistor, the teensy pin must only allow the signal to tell the mosfet/transistor to turn off or on. There are relay boards and mosfet breakouts you can find on adafruit, or build one using simple online circuits
 
Status
Not open for further replies.
Back
Top