---
# System prepended metadata

title: Untitled

---

#蜂鳴器

```javascript=

void setup()
{
}

void loop()
{
  tone(D4, 440);
  delay( 1000 );
  noTone(D4);
}

```

![](https://i.imgur.com/bC9Qjvv.jpg)


#超音波

```javascript=


#include <Ultrasonic2.h>

int Range = 0 ;
Ultrasonic2 monUltrasonic_pin5(5);

void setup()
{
Serial.begin(9600);
}

void loop()
{
Range = monUltrasonic_pin5.mesurer(6) ;
Serial.print(“Distance=”);
Serial.print(Range);
Serial.print(" ");
Serial.println();
delay( 200 );
}
```


#閃燈

```javascript=


void setup()
{
  pinMode( D4 , OUTPUT);
}

void loop()
{
  digitalWrite(D4 , LOW);
  delay( 1000 );/*關1秒*/
  digitalWrite(D4 , HIGH);
  delay( 1000 );/*開1秒*/
}

```



#紅外線
```javascript=
int Range = 0 ;
boolean __ardublockDigitalRead(int pinNumber)
{
  pinMode(pinNumber, INPUT);
  return digitalRead(pinNumber);
}



void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Range = __ardublockDigitalRead(D2) ;
  Serial.print("Distance=");
  Serial.print(Range);
  Serial.print(" ");
  Serial.println();
  delay( 200 );
}
```

https://drive.google.com/file/d/1Pk59in3G1KsMN-S6lhNX7ANi2hWYYZf3/view?usp=share_link

https://drive.google.com/file/d/1JuckParcxTs3uVRoVsFWnaETNg1yVCCM/view?usp=share_link

![](https://i.imgur.com/nwnkRWl.png)


![](https://i.imgur.com/ifNM9DC.png)
