cpuTemperature()

描述

读取 86Duino CPU 的温度。在 86Duino Coding 102 版本以后才可以使用这个函式。

语法


cpuTemperature(mode)
cpuTemperature()

参数

mode: DEGREE_C,或 DEGREE_F 代表读取的温度单位为摄氏 (°C) 或华氏 (°F)。预设是以摄氏为单位。

回传

CPU 温度值 (double)

范例

double val1 = 0.0;
double val2 = 0.0; 

void setup()
{
  Serial.begin(9600);
}
 
void loop()
{
  val1 = cpuTemperature(); // 温度单位预设是摄氏
  val2 = cpuTemperature(DEGREE_F); // 改用华氏为单位
  Serial.print(val1);            
  Serial.print("   ");           
  Serial.println(val2);            
  delay(100);
}

语法参考主页面

本页由热血青年 LBU 译自英文版。

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.