I am hoping Amedee can share the UNO sketch and breadboard layout so I can test the new fans I bought.
If they work in this setup, I can consider putting them in my UMO
(reference: viewtopic.php?f=7&t=74&start=45#p859)
PWM test sketch for Arduino UNO?
- Amedee
- Reactions:
- Posts: 599
- Joined: February 15th, 2016, 11:10 am
- Location: Brussels, Belgium
- 3D Printer(s): UMO / UMO+
- Contact:
Re: PWM test sketch for Arduino UNO?
You have some transistor in house?
- LePaul
- Reactions:
- Posts: 3973
- Joined: February 7th, 2016, 10:26 pm
- Location: Bangor, Maine USA
- 3D Printer(s): 24 - Yes I have a problem!
- Contact:
Re: PWM test sketch for Arduino UNO?
I might! I have all the contents of the Sparkfun Inventor's Kit and a few odds and ends ![Smile :)](./images/smilies/icon_e_smile.gif)
![Smile :)](./images/smilies/icon_e_smile.gif)
- Amedee
- Reactions:
- Posts: 599
- Joined: February 15th, 2016, 11:10 am
- Location: Brussels, Belgium
- 3D Printer(s): UMO / UMO+
- Contact:
Re: PWM test sketch for Arduino UNO?
If you can give me the reference of what you have and also the Amp rating of your fan, I can check if it will work and which resistor we need...
You probably need a flyback diode as well (1N400x or whatever) unless the transistor has one builtin.
You probably need a flyback diode as well (1N400x or whatever) unless the transistor has one builtin.
- Amedee
- Reactions:
- Posts: 599
- Joined: February 15th, 2016, 11:10 am
- Location: Brussels, Belgium
- 3D Printer(s): UMO / UMO+
- Contact:
Re: PWM test sketch for Arduino UNO?
You are all set ![Wink ;)](./images/smilies/icon_e_wink.gif)
So you need something like this: For the transistor & diode, use what you have.
For the resistor, to be safe use 2 330 Ohms in series.
That gives us on the breadboard Now, be careful with the transistor, you need the minus on the emitter and the fan/diode on the collector side (I find the drawing confusing)
Batteries are your 12V battery
Sketch in next episode![Wink ;)](./images/smilies/icon_e_wink.gif)
![Wink ;)](./images/smilies/icon_e_wink.gif)
So you need something like this: For the transistor & diode, use what you have.
For the resistor, to be safe use 2 330 Ohms in series.
That gives us on the breadboard Now, be careful with the transistor, you need the minus on the emitter and the fan/diode on the collector side (I find the drawing confusing)
Batteries are your 12V battery
Sketch in next episode
![Wink ;)](./images/smilies/icon_e_wink.gif)
- LePaul
- Reactions:
- Posts: 3973
- Joined: February 7th, 2016, 10:26 pm
- Location: Bangor, Maine USA
- 3D Printer(s): 24 - Yes I have a problem!
- Contact:
Re: PWM test sketch for Arduino UNO?
Can the USB provide enough power?
- Amedee
- Reactions:
- Posts: 599
- Joined: February 15th, 2016, 11:10 am
- Location: Brussels, Belgium
- 3D Printer(s): UMO / UMO+
- Contact:
Re: PWM test sketch for Arduino UNO?
Here it is...
Note that all this is untested ![Wink ;)](./images/smilies/icon_e_wink.gif)
Code: Select all
/*
PWM Fan Test
*/
/*
Arduino Pin assignement
*/
// Digital
const int usbSerialRxPin = 0; // Reserved
const int usbSerialTxPin = 1; // Reserved
const int fanPin = 3; // Fan control (pwm)
/*
Globals
*/
uint8_t fanSpeed = 0; // Start as ...
/*
Setup routine
*/
void setup() {
// Serial
Serial.begin(9600);
// Fan pin setup
pinMode(fanPin, OUTPUT);
analogWrite(fanPin, fanSpeed);
Serial.println("Setup done");
Serial.println("Enter desired fan speed (0-100%)");
}
/*
Main loop
*/
void loop() {
// Check input
if (Serial.available()) {
long i = Serial.parseInt();
if (i < 0 || i > 100) {
Serial.println("Invalid input");
} else {
Serial.print("Setting fan to ");
Serial.print(i);
Serial.println("%");
fanSpeed = 255 * i / 100;
analogWrite(fanPin, fanSpeed);
}
}
}
![Wink ;)](./images/smilies/icon_e_wink.gif)
- Amedee
- Reactions:
- Posts: 599
- Joined: February 15th, 2016, 11:10 am
- Location: Brussels, Belgium
- 3D Printer(s): UMO / UMO+
- Contact:
Re: PWM test sketch for Arduino UNO?
USB powers the Arduino.LePaul wrote:Can the USB provide enough power?
You should power the fan separately (I remember I saw A 12v battery in one of your pictures)
- LePaul
- Reactions:
- Posts: 3973
- Joined: February 7th, 2016, 10:26 pm
- Location: Bangor, Maine USA
- 3D Printer(s): 24 - Yes I have a problem!
- Contact:
Re: PWM test sketch for Arduino UNO?
Oh yes have many of those