DrDiettrich:
Connect the black wire to Gnd, and yellow to PWM.
It’s a 4 wire fan with it’s own power supply and even own chip to drive it.
Can the arduino mega stand 1.8 amps max on the pwm-pin?
Here this guy got it running but i still don’t understand his code, he uses an Arduino uno i guess.
Turbine: Delta Electronics BFB1012VH-5D84
Picture of its and schematic in the attachments. The blue circuit is just this sensor cable. Yellow is PWM.
#include <Wire.h>
#include <TimerOne.h>
#include <LiquidCrystal_I2C.h> // pobrany lib od I2C
#define btnUp 4
#define btnDown 5
#define ctrlPwm 3
#define sensePin 2
// LCD na 0x3F
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6 ,7, 3, POSITIVE);
// speed
unsigned int ctrl;
unsigned int pwm;
unsigned int rpm;
unsigned int counts;
void licznik() {
counts++;
}
void pomiarRPM() {
Timer1.detachInterrupt();
rpm = counts;
counts=0;
Timer1.attachInterrupt(pomiarRPM);
}
void bar() {
switch (ctrl){
case 1:
lcd.setCursor(5,0);
lcd.print("");
break;
case 2:
lcd.print("[# ]");
break;
case 3:
lcd.print("[## ]");
break;
case 4:
lcd.print("[### ]");
break;
case 5:
lcd.print("[#### ]");
break;
case 6:
lcd.print("[##### ]");
break;
case 7:
lcd.print("[###### ]");
break;
case 8:
lcd.print("[####### ]");
break;
case 9:
lcd.print("[######## ]");
break;
case 10:
lcd.print("[#########]");
break;
}
}
void sterowanie() {
while(digitalRead(btnUp) == LOW){
if(ctrl < 10){
ctrl++;
lcd.setCursor(5,0);
bar();
delay(200);
} else {
lcd.setCursor(5,0);
lcd.print("[ - MAX - ]");
delay(200);
}
}
while(digitalRead(btnDown) == LOW){
if(ctrl > 1){
–ctrl;
lcd.setCursor(5,0);
bar();
delay(200);
} else {
lcd.setCursor(5,0);
lcd.print("[ - MIN - ]");
delay(200);
}
}
}
void regulacja() {
unsigned int spd;
spd = ctrl*20+55;
// sprawdzenie czy za wolno
if(pwm < spd){
for (pwm; pwm < spd; pwm++) {
analogWrite(ctrlPwm, pwm);
delay(50);
lcd.setCursor(3,1);
lcd.print((pwm/10)*4);
lcd.print("%");
}
} else {
}
// sprawdzenie czy za szybko
if(pwm > spd){
for (pwm; pwm > spd; --pwm) {
analogWrite(ctrlPwm, pwm);
delay(50);
lcd.setCursor(3,1);
lcd.print((pwm/10)*4);
lcd.print("%");
}
} else {
}
lcd.clear();
}
void setup() {
// sterowanie (przyciski)
pinMode(btnUp, INPUT_PULLUP);
pinMode(btnDown, INPUT_PULLUP);
pinMode(ctrlPwm, OUTPUT);
// pomiar
pinMode(sensePin, INPUT);
Timer1.initialize(500000); // 0,5 sekund
attachInterrupt(digitalPinToInterrupt(sensePin), licznik, RISING);
Timer1.attachInterrupt(pomiarRPM);
// reset zmiennych
ctrl = 1;
pwm = 0;
// wyswietlacz
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("REG: ");
lcd.setCursor(0,1);
lcd.print("P: ");
lcd.setCursor(8,1);
lcd.print("R: ");
}
void loop() {
unsigned int spd;
spd = ctrl*20+55;
// czytanie przyciskow
sterowanie();
// uruchomienie
if(pwm == 0){
analogWrite(ctrlPwm, 75);
pwm = 75;
} else {
}
// sprawdzanie
if(pwm != spd){
regulacja();
} else {
lcd.setCursor(0,0);
lcd.print("REG: ");
bar();
lcd.setCursor(0,1);
lcd.print(“P: “);
lcd.print((pwm/10)*4);
lcd.print(”%”);
}
lcd.setCursor(8,1);
lcd.print("R: ");
lcd.print(rpm);
delay(25);
//koniec
}