Salvaged part project

I am playing with a SparkFun experimenter kit that includes a servo motor. The tutorial code is complicated (to a beginner) and the effect is difficult to follow. The Inventor’s Guide mentions libraries, and provides a link: arduino.cc/en/Reference/Libraries. The example that I am looking at is the potentiometer knob. A knob came with my kit. I wired it up. Twist the knob one way, the servo turns the same direction, 180 both ways. Cool! Simple enough even I can understand it. In a bag of micro parts salvaged from busted gadgets I noticed a cooling fan with three wires. I want to try it with the knob-server code. My question is, before I attach pins to the wires so it will plug into a breadboard, can I expect the fan to respond like a servo? And, if not, why does a cooling fan have 3 wires? Any referrals to projects that explain a 3-wire fan are appreciated.

Never seen a three-wire fan. Could you be so kind to share some photos of it.

The 3 wires are probably power, ground and rpm pulse signal (it’s a sense-output, not to give desired speed). The pulses are likely generated by a magnet passing by a hall-sensor. A photo would help to identify the likely wire colors. Since the Arduino or whatever does not have enough power in it’s output pins to make it rotate hooking it up to that does little for you. Hooking it up to the 5 volt and ground pin of the board should supply it with enough atleast attempt to turn, once you tried the right wires. Once you identified the rpm-wire then you could connect it to a pin, set as input!, and use the PulseIn command to measure the duration of the pulse, or the duration between the pulses. Or use digitalRead to count how often it goes high from low, within a certain time period. The RPM would then be the number of pulses you can count in that timeframe.

It will definitely not turn like a servo and stop where you want it. And it will only turn one way to make the air move. The frequency of RPM pulses are a measure of how much airflow you’ll get.

As for projects you only have to ask Google about “arduino PC fan controller”. There are too many to mention.

The fan I salvaged is not at hand. In the meantime, I searched and found a simple circuit for a 3-wire fan. Try this link: https://create.arduino.cc/projecthub/po … sor-265798. The project description mentions a Hall effect sensor. It looks to me like the fan speed prints to the serial monitor. A push button switch is used in the wiring scheme. I would try a potentiometer. A potentiometer has VCC, GND, and PWM wires. When I get my hands on my salvage fan, I will attach breadboard pins to the wires and research putting together a sketch by combining elements of existing code. I will also provide a photo.

A potentiometer is a variable resistor, not a pulse generator. It has 3 terminals, the center one touching the resistive element somewhere along it. This allows you to use it as a voltage divider for the 2 voltages connected to either end. But if you apply 2 different voltages to either side, the center one is not going to give out rectangular repetitive pulses. As that is what PWM means. Pulse-Width-Modulation. When applied some devices will act like it receives an analog voltage or behave in a gradual fashion, but the underlying signal is very much digital. You will have to connect it to one of the analog pins and measure the level with the AnalogRead function to turn it into a number.

Feel free to experiment with that and research. But you may have gotten the wrong idea about what PWM means or what potentiometers do.

That tutorial is nice to get something going. But I fear it won’t teach you much about the code. The interesting part, how it works is hidden in the library covered between class-structuring code. Not something I would suggest beginners to start with.

This one has all the code in one file for you to look at. It does use an interrupt to call the function that does the counting. (somewhat higher level than beginners) But it is nicely commented telling what it does.

http://www.themakersworkbench.com/conte … pm-arduino

I think I see the difference between pulse and divider. I just tried the circuit again. The potentiometer could be replaced by two push button switches, turn right and turn left. The servo doesn’t actually turn the same degrees as the knob. A turn of any degree either way rotates the servo full 90 in that direction. That’s what is meant by dividing, right? A pulse would turn the servo a specific degree. There are other problems with this sketch I don’t even want to ask about.

This is an example of a library file: ```
#include <Servo.h>

Yes, but only part of it. It says to read a header file (.h) for that library. That line says to the compiler that it needs to read that file to learn about constants, variables and the names of functions that it uses. But it does not contain the actual code. Those are usually found in .c or .cpp files. It will automatically include the .c or .cpp files with the same name if they can be found in a specific folder.

The width or length of a pulse (in time, between 1 and 2 miliseconds for either end) would turn the servo to a specific degree. In general a common servo motor (originally meant for radio control vehicles) needs a repetitive signal. The signal is mostly 0 volt, except during the pulse when it is full voltage. You made it turn to one extreme end because it considered the constant voltage as the longest pulse.

A potentiometer, or a voltage divider made with 2 fixed resistors in series works completely different. It gives a voltage on the center point that is based on the ratio of R1/(R1+R2). i.e. if R1= 1000 ohm, and R2 is 2000 ohm, R1 is connected to 0 volt and R2 is connected to 5 volt. Then the leads between the resistors have the voltage of 5 volt * 1000/3000=1,667 volt. If you change the voltages on either end, the voltage in the middle changes based on the ratio and the voltage difference across them both.

There’s a page about voltage dividers, which I expect to return to again and again, includiing potentiometers: https://learn.sparkfun.com/tutorials/voltage-dividers. Thanks for keeping the thread alive. I set up the experiment for reading a fan. The fan spins when the button is pushed, but the serial monitor prints gibberish: ```
°°° °°¸°°°¸¸ °°ì¤ à ¾°°°° ° ¸°à ¸¬ ¤¤ ´ô¶¢°ð ¸

Did you set the serial monitor to the correct baudrate, as in the code? Serial.begin(115200);

If so, disconnect the power from the fan. Maybe the fan causes electrical noise disturbing the redboard. The redboard should send out readable serial data even if the fan is not connected. [EDIT] What kind of switch is it? That is probably enough to prevent power from going to the fan.

Yes, I tried the other baudrates. The characters got larger and larger, but still gibberish. I am having second thoughts about this experiment. The author says he had to try several fans to find one that printed to the serial monitor. Any casual reader of this thread might not have even one to play with. Hard to replicate any experiment without the needed parts! I am calling it a half-success. Something is printing to the serial monitor. The fans spins. If I were designing a cooling fan and I wanted it to spin faster and slower according to rising and falling temperature, I would use a temperature sensor.

You should not try other baudrates, you should set the exact value as given. The setting in the serial monitor should match with what is set with Serial.begin in the program.