This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() {//這裡面要放最一開始執行的程式碼 | |
pinMode(LED_BUILTIN, OUTPUT); | |
} | |
void loop() {//此處程式碼會不斷地執行 | |
digitalWrite(LED_BUILTIN, HIGH); //把一個燈泡點亮(HIGH就是亮) | |
delay(1000); //讓它亮1秒(1000毫秒=1秒) | |
digitalWrite(LED_BUILTIN, LOW); //燈泡暗了(LOW就是暗) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int trigPin = 12; | |
int echoPin = 11; | |
long duration, cm, inches; | |
void setup(){ | |
Serial.begin(9600); | |
pinMode(trigPin, OUTPUT); //Define input and output | |
pinMode(echoPin, INPUT); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int PIRSensor=2; //紅外線接腳 | |
const int ledPin=13; //LED接腳 | |
int tmp; | |
int sensorValue=0; | |
int buzzerPin=9; //蜂鳴器接腳 | |
void setup(){ //設定輸入輸出 | |
pinMode(PIRSensor, INPUT); | |
pinMode(ledPin, OUTPUT); | |
pinMode(buzzerPin, OUTPUT); |
NewerOlder