SPEED CONTROL DC FAN

In this project we will demonstrate controlling DC motor speed. In the diagram, button 1 is used for set of speed values ​​whose value will be stored in the EEPROM, when the speed setting, this button 1 will be pressed along with keys 2 or 3, lowering the value or increasing the rate value is done with keys 2 and 3.

DC fan speed control1

The code can be downloaded at:

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/FAN%20SPEED.zip

#include <EEPROM.h>
int pinIncrease = 2;
int pinDecrease = 3;
int pinLED = 11;
int pinSetting = 10;
int SpeedFan;
byte laju;
void setup() {
Serial.begin(9600);
pinMode(pinIncrease, INPUT);
pinMode(pinDecrease, INPUT);
pinMode(pinSetting, INPUT);
pinMode(pinLED, OUTPUT);
digitalWrite(pinIncrease, HIGH);
digitalWrite(pinDecrease, HIGH);
}
void loop() {
if(digitalRead(pinSetting) == HIGH){
laju = EEPROM.read(1);
SpeedFan = constrain(SpeedFan, 0, 255);
analogWrite(pinLED, laju);
EEPROM.write(1, SpeedFan);
laju = EEPROM.read(1);
Serial.print(laju);
Serial.print(” “);
Serial.println(SpeedFan);
delay(20); setting();
}else if(digitalRead(pinSetting) == LOW){
laju = EEPROM.read(1);
SpeedFan=laju;
analogWrite(pinLED, laju);
Serial.print(laju);
Serial.print(” “);
Serial.println(SpeedFan);
delay(20);
}
}
void setting(){
if(digitalRead(pinIncrease) == LOW){
SpeedFan++;
}else if(digitalRead(pinDecrease) == LOW){
SpeedFan–;
}
}

3 thoughts on “SPEED CONTROL DC FAN

  1. saya sudah coba upload code nya.
    up/ down speed brfungsi dgn baik, dgn menekan tmbol set, speed pada fan tersimpan di eeprom.
    setelah arduino di reset, speed fan sesuai speed yg sudah di set, hanya saja jika menekan tombol up/ down, speed fan berubah mulai dari nol, tidak akumulatif dari speed fan yg sudah di set.
    mohon bimbingan nya kak

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s