Function to measure a distance with an ultrasonic sensor

This commit is contained in:
Laure BEL 2024-03-11 09:10:19 +01:00
parent 66c4cd0ab4
commit 4453fbea1a
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#include "Arduino.h"
#include "Wire.h"
#include "MeMCore.h"
#include "SoftwareSerial.h"
MeUltrasonicSensor ultrasonicSensor(PORT_3);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
delay(2000);
Serial.println(ultrasonicSensor.distanceCm());
}