Skip to content

Alexopro/Speed-fan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Speed-fan - Управление скоросью куллера

  1. Оглавление

  1. English

1.1. Folders

  1. Русский

2.1. Папки

1. English

1.1. Folders

Speed_fan/Speed_fan.ino - Code file

Code

//-----------------------------
//Constant pins buttons and fan
//-----------------------------
const int Button1 = 11;
const int Button2 = 12;
const int Button3 = 13;
const int Fan = 3;

//-----------------------------
//Setting pins
//-----------------------------

void setup() {
  //Serial.begin(9600);//Debug
  pinMode (Button1, INPUT_PULLUP);
  pinMode (Button2, INPUT_PULLUP);
  pinMode (Button3, INPUT_PULLUP);
  pinMode (Fan, OUTPUT);
}

byte Speed;//Var speed fan

//-----------------------------
//Function scan button
//-----------------------------

byte Button()
{
  if (digitalRead (Button1) == LOW)
  {
    Speed = 0;
  }

  if (digitalRead (Button2) == LOW)
  {
    Speed = 100;
  }

  if (digitalRead (Button3) == LOW)
  {
    Speed = 255;
  }
  delay(10);
  return Speed;
}

//-----------------------------
//General loop
//-----------------------------

void loop()
{
  Button();
  analogWrite (Fan, Button());
  //-----------------------------
  //DEBUG
  //-----------------------------
  /*
    Serial.print("Speed ");
    Serial.println(Button());
    Serial.print("sign ");
    Serial.println(analogRead(A0));
  */
}

2. Русский

2.1. Папки

Speed_fan/Speed_fan.ino - Файл с кодом

Код

//-----------------------------
//Выбор контактов поключения кнопок и кулера к ардуино
//-----------------------------
const int Button1 = 11;
const int Button2 = 12;
const int Button3 = 13;
const int Fan = 3;

//-----------------------------
//Настройка подключения
//-----------------------------

void setup() {
  //Serial.begin(9600);//Debug
  pinMode (Button1, INPUT_PULLUP);
  pinMode (Button2, INPUT_PULLUP);
  pinMode (Button3, INPUT_PULLUP);
  pinMode (Fan, OUTPUT);
}

byte Speed;//Var speed fan

//-----------------------------
//Функция для определения нажатий клавиш
//-----------------------------

byte Button()
{
  if (digitalRead (Button1) == LOW)
  {
    Speed = 0;
  }

  if (digitalRead (Button2) == LOW)
  {
    Speed = 100;
  }

  if (digitalRead (Button3) == LOW)
  {
    Speed = 255;
  }
  delay(10);
  return Speed;
}

//-----------------------------
//Основной цикл
//-----------------------------

void loop()
{
  Button();
  analogWrite (Fan, Button());
  //-----------------------------
  //Отладка
  //-----------------------------
  /*
    Serial.print("Speed ");
    Serial.println(Button());
    Serial.print("sign ");
    Serial.println(analogRead(A0));
  */
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages