某牌溫度感測器 讀不到訊號

astro1abe發佈於2020-05-29 15:19:06

瀏覽5651

回覆2

最後編輯於2024-04-26 21:34:49

市售的溫度感測器,有電源導通,但D13一直收不到信號〈黃色LED沒亮〉,代碼如下

#define DO 13


void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Temp test!");
  pinMode(13, INPUT);
}

void loop() 
{
  delay(2000);
  // put your main code here, to run repeatedly:
  float t = digitalRead(DO);
  Serial.print("  Temperature: ");
  Serial.println(t);
}

共2條回覆 最後由EricYang回覆於2020-05-29 21:22:16
#1
Kochingchang 回覆於 2020-06-15 17:20:59

AO:類比輸出。
DO:數位輪出,達到內定值輪出"HIGH",否則"LOW"
請將AO接DSI5168 A0或A1.
 

int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  Serial.begin(115200);
  Serial.println("Temp test!");
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);

  Serial.print("  Temperature: ");
  Serial.println(sensorValue);
}

 

#2
EricYang 回覆於 2020-05-29 21:22:16

不確定您用的感測器模板型號為何,但 Dout 一般來說是準位超出標準時才會有輸出 而讀取方式都是以 Analog 為主