2015年7月23日 星期四

Arduino using PWM Controlled a Fan

//Arduino Fan Control

//  * SoftwarePWM.pde
const int pin = 3;
boolean Q=1;
void setup()
{
  pinMode(pin, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  if (Q) {
    FullRun();
  }

 int sensorValue = analogRead(A0);
 int sensor1 = map(sensorValue, 0, 1023, 0 ,255);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.print("Analog VR Read: ");
  Serial.print(sensor1);
  Serial.print("   Voltage:  Analoag Read * (5.0 / 1023.0)= ");
  Serial.println(voltage);

  analogWrite(pin, sensor1);
 }
//==========================================

void FullRun() {
analogWrite(pin, 255);
delay(1500);
Q=0;
}
//==========================================





沒有留言:

張貼留言

RFID TI 培訓影片系列

RFID TI 培訓影片系列  https://www.ti.com/zh-tw/video/series/rfid.html 培訓影片系列 RFID 隨著創新技術日益發展,RFID 和 RF 術語越來越容易讓人混淆。本訓練系列詳細介紹了使用案例、權衡技術優缺點,讓您清楚知道該選...