หน้าแรก ดูโปรเจกต์ทั้งหมด
Expert

โปรเจกต์ การ Control Fan แบบ 4-Wired (PWM)

การ Control PWM Fan ด้วย Arduino

โปรเจกต์ การ Control Fan แบบ 4-Wired (PWM)
}

รายละเอียดและวิธีทำ

ผมแค่ต้องการควบคุมพัดลมแบบ 4 สาย (หรืออาจจะหลายตัว) ด้วย Board Arduino มีข้อมูลเกี่ยวกับเรื่องนี้อยู่บ้าง มีหลายโปรเจกต์ที่ใช้ Sensor วัดอุณหภูมิ แต่กลับไม่มีเรื่องพื้นฐานที่ง่ายที่สุดอย่างการควบคุมความเร็วของพัดลมเลย

ผมพบ Code ที่มีประโยชน์ใน Thread นี้: https://forum.arduino.cc/index.php?topic=155089.msg1175321#msg1175321

int pwmPin     = 3; // digital PWM pin 9
int pwmVal = 1; // The PWM Value
unsigned long time;
unsigned int rpm;
String stringRPM;
void setup()
{
// generate 25kHz PWM pulse rate on Pin 3
pinMode(pwmPin, OUTPUT); // OCR2B sets duty cycle
// Set up Fast PWM on Pin 3
TCCR2A = 0x23; // COM2B1, WGM21, WGM20
// Set prescaler
TCCR2B = 0x0A; // WGM21, Prescaler = /8
// Set TOP and initialize duty cycle to zero(0)
OCR2A = 79; // TOP DO NOT CHANGE, SETS PWM PULSE RATE
OCR2B = 0; // duty cycle for Pin 3 (0-79) generates 1 500nS pulse even when 0 :
digitalWrite(2, HIGH); // Starts reading
Serial.begin(9600);
}
void loop()
{
unsigned int x;
// ramp up fan speed by increasing duty cycle every 200mS, takes 16 seconds
//for(x = 0; x < 80; x++) {
// OCR2B = x; // set duty cycle
// getRPMS();
// Serial.println(x);
// delay(200);
//}
while (Serial.available() == 0);
int val = Serial.parseInt();
if (val > 0 && val < 80) {
OCR2B = val;
}
}
char getRPMS() {
time = pulseIn(2, HIGH);
rpm = (1000000 * 60) / (time * 4);
stringRPM = String(rpm);
if (stringRPM.length() < 5) {
Serial.println(rpm, DEC);
}
}

การต่อวงจร (Wiring):

Code

🔒 ปลดล็อก Code

สนับสนุนเพื่อรับ Source Code หรือแอปพลิเคชันสำหรับโปรเจกต์นี้

รหัสอ้างอิงโปรเจกต์: 4-wired-fan-control-pwm-a25fa6
870 บาท
PromptPay QR Code