Update sketchDistanceSerial-Ultrasonic.ino

This commit is contained in:
Cédric Abonnel 2022-05-15 21:48:32 +00:00
parent ec3e862530
commit d51ff806cc
1 changed files with 11 additions and 4 deletions

View File

@ -1,13 +1,20 @@
#include "Ultrasonic.h"
Ultrasonic sensor(8,9); // Trig et Echo
#define echoPin 9 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin 8 //attach pin D3 Arduino to pin Trig of HC-SR04
Ultrasonic sensor(trigPin,echoPin); // Trig et Echo
// defines variables
int distance; // variable for the distance measurement
void setup() {
Serial.begin(9600);
pinMode (11, OUTPUT);
pinMode (12, OUTPUT);
Serial.begin(9600);trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
Serial.println("with Arduino UNO R3 and Ultrasonic.h");
}
void loop () {