zed_com

Проект "Вентелятор"

Jun 15th, 2020
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. int baselineTemp = 0;
  2. int celsius = 0;
  3. int fahrenheit = 0;
  4. int speedMotor = 0;
  5.  
  6. void setup()
  7. {
  8.   pinMode(A0, INPUT);
  9.   Serial.begin(9600);
  10.  
  11.   pinMode(3, OUTPUT);
  12. }
  13.  
  14. void loop()
  15. {
  16.  baselineTemp = 40;
  17.   // measure temperature in Celsius
  18.   celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125);
  19.   speedMotor = map(((analogRead(A0) - 20) * 3.04), 0, 1023, 0, 255);
  20.   fahrenheit = ((celsius * 9) / 5 + 32);
  21.   Serial.print(celsius);
  22.   Serial.print(" C, ");
  23.   Serial.print(fahrenheit);
  24.   Serial.println(" F");
  25.   analogWrite(3, speedMotor);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment