---
# System prepended metadata

title: "\ntest: TCRT5000 (紅外線)\n"

---

<h1>
<i>test:</i> TCRT5000 (紅外線)
</h1>

<h2>
Code
</h2>

```arduino=
#define digitalPin0 A0  //前置命令定義analogPin來自於A0
#define digitalPin1 A1
#define digitalPin2 A2
#define digitalPin3 A3
#define digitalPin4 A4

void setup()
{
  pinMode(digitalPin0, INPUT); // 目前預設該接腳作為輸入
  pinMode(digitalPin1, INPUT);
  pinMode(digitalPin2, INPUT);
  pinMode(digitalPin3, INPUT);
  pinMode(digitalPin4, INPUT);
  
  Serial.begin(9600);//表示開始傳遞與接收序列埠資料
}

void loop()
{
  Serial.print(digitalRead(digitalPin0));  //將數值印出來
  Serial.print(digitalRead(digitalPin1));  //將數值印出來
  Serial.print(digitalRead(digitalPin2));  //將數值印出來
  Serial.print(digitalRead(digitalPin3));  //將數值印出來
  Serial.print(digitalRead(digitalPin4));  //將數值印出來
  
  Serial.print("\n");  //將數值印出來
  
  delay(500); //延遲0.5秒
}
```

<h2>
Result
</h2>

<p>
1.initial state<br>
<img src ="https://i.imgur.com/cY6bStu.png" title ="all zeroes">
</p>

<p>
2.upon raised
<img src ="https://i.imgur.com/um02raO.png" title ="all zeroes -> all ones">
</p>

<p>
3.finger fluctuating in front of it
<img src ="https://i.imgur.com/iPfvAFh.png" title ="a zero wave">
</p>

