Make sure that your power supply has enough power to control the fan motor as well. Then make sure that your program is referencing the correct pin. Make sure that the output for the FET is wired to a pin that can output PWM. This program has not been tested and is intended as an example. converter to settle after the last reading: wait 2 milliseconds before the next loop for the analog-to-digital map it to the range of the analog out: Int outputValue = 0 // value output to the PWM (analog out) Int sensorValue = 0 // value read from the pot They're used to give names to the pins used:Ĭonst int analogInPin = A0 // Analog input pin that the potentiometer is attached toĬonst int analogOutPin = 9 // Analog output pin that the FET is attached to The following program is adapted from the "Analog In, Out Serial" built-in example and should be sufficient to control the speed of the motor. Luckily, there is a tutorial on the Arduino website for driving motors with PWM through a FET. According to the Arduino documentation, the microcontroller can only provide 20mA per output pin, which is enough to drive LEDs but not fan motors. The Arduino simply can't put provide the current required to drive the fan. Like people have already mentioned in the comments, you likely need to add a FET to drive the fan. put your main code here, to run repeatedly: put your setup code here, to run once: I have an voltage supply connected to a breadboard to power the fan.Īdditionally, would I require a mosfet or transistor despite using a potentiometer? This could have also be the problem regarding my second attempt. In the second code, the fan also did not come on. I assume that this was due to an error in the first code. When I have run the code and varied the potentiometer, the LED on the power supply changed but, the fan did not come on. Initially, I assumed that I could go about doing so by using a code that I used for dimming an LED. I am trying to vary the speed of a 2-wire fan by using a Arduino Uno and only a potentiometer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |