Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anechas/arduino-ultrasonic-sensor-simple
arduino ultrasonic sensor HC-SR04
https://github.com/anechas/arduino-ultrasonic-sensor-simple
aduino hc-sr04 netpie nodemcu-esp8266 ultrasonic-sensor zx-led
Last synced: 10 days ago
JSON representation
arduino ultrasonic sensor HC-SR04
- Host: GitHub
- URL: https://github.com/anechas/arduino-ultrasonic-sensor-simple
- Owner: AnechaS
- Created: 2019-11-09T22:05:15.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-04-05T19:47:35.000Z (almost 3 years ago)
- Last Synced: 2024-11-06T21:45:53.233Z (about 2 months ago)
- Topics: aduino, hc-sr04, netpie, nodemcu-esp8266, ultrasonic-sensor, zx-led
- Language: C++
- Homepage:
- Size: 155 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Arduino Ultrasonic Sensor Simple
Sensor module to measure the distance 2cm to 400 cm## Equipment used
* Ultrasonic HC-SR04
* NodeMCU v2.0
* Breadboad
* Jumper wire### Complete the circuit assembly as shown below.
![alt text](.github/esp-sr04.png)### Basic code ultrasonic HC-SR04
```c++
#define TRIGGER_PIN 5
#define ECHO_PIN 4void setup() {
pinMode(TRIGGER_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(BUILTIN_LED, OUTPUT);Serial.begin (9600);
}void loop() {
long duration, distance;digitalWrite(TRIGGER_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGGER_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGGER_PIN, LOW);duration = pulseIn(ECHO_PIN, HIGH);
distance = duration * 0.034 / 2;Serial.print(distance);
Serial.println(" cm");
delay(1000);
}
```