เครื่องช่วยจอดรถ
อุปกรณ์
Arduino Nano แถมสาย USB https://raka.is/r/Jzgk
HC-SR04 Ultrasonic Sensor Module https://raka.is/r/ejen
โฟโต้บอร์ด https://raka.is/r/BJpQ
โค้ด
#define Trig 2
#define Echo 3
const int LED = 4;
long duration;
int distance;
void setup() {
pinMode(LED, OUTPUT);
pinMode(Trig, OUTPUT);
pinMode(Echo, INPUT);
}
void loop() {
digitalWrite(Trig, LOW);
delayMicroseconds(5);
digitalWrite(Trig, HIGH);
delayMicroseconds(10);
digitalWrite(Trig, LOW);
duration = pulseIn(Echo, HIGH);
distance = duration * 0.034 / 2;
if (distance <= 20)
{
digitalWrite(LED, HIGH);
delay(40);
}
else {
digitalWrite(LED, LOW);
}
}
「hc-sr04 echo」的推薦目錄:
- 關於hc-sr04 echo 在 Audom Idea Facebook 的精選貼文
- 關於hc-sr04 echo 在 Audom Idea Facebook 的最讚貼文
- 關於hc-sr04 echo 在 How to use HC-SR04 Ultrasonic Sensor with ... - YouTube 的評價
- 關於hc-sr04 echo 在 what is this IC and pin on the HC-SR04 which is being used ... 的評價
- 關於hc-sr04 echo 在 Why is my HC-SR04 ultrasonic distance sensor not working ... 的評價
- 關於hc-sr04 echo 在 超音波距離感測器HC-SR04 - Gist de GitHub 的評價
hc-sr04 echo 在 Audom Idea Facebook 的最讚貼文
ทำเครื่องกดเจลล้างมืออัตโนมัติแบบพกพา
คลิป https://www.youtube.com/watch?v=xRvFsj59aZM
วัสดุที่ใช้
1.Arduino nano
2.Ultrasonic Module HC-SR04
3.เซอโว
4.สายจั๊มเปอร์
5.รางถ่าน aa3ก้อน
---------------------------------------------
โค้ด
#define Trig 2
#define Echo 3
#include <Servo.h>
Servo myservo;
Servo myservo1;
long duration;
int distance;
void setup() {
myservo.attach(A0);
myservo1.attach(A1);
pinMode(Trig, OUTPUT);
pinMode(Echo, INPUT);
}
void loop() {
digitalWrite(Trig, LOW);
delayMicroseconds(5);
digitalWrite(Trig, HIGH);
delayMicroseconds(10);
digitalWrite(Trig, LOW);
duration = pulseIn(Echo, HIGH);
distance = duration * 0.034 / 2;
if (distance <= 20)
{
myservo.write(50);
myservo1.write(0);
delay(2000);
}
else {
myservo.write(0);
myservo1.write(50);
delay(500);
}
}
hc-sr04 echo 在 what is this IC and pin on the HC-SR04 which is being used ... 的推薦與評價
The Arduino source code used for measuring two echoes is as follows. The first object is detected using the Echo lead of the HC-SR04 per ... ... <看更多>
hc-sr04 echo 在 How to use HC-SR04 Ultrasonic Sensor with ... - YouTube 的推薦與評價
SunFounder HC - SR04 consists of ultrasonic transmitter, receiver, and control circuit. Mode of Connection: VCC/ trig(T)/ Echo (R)/ GND (VCC ... ... <看更多>