Added the Ultrasonic sensor file and the code to find the distance in front of the robot.

This commit is contained in:
Mattis ROELLINGER 2024-03-11 09:28:19 +01:00
parent adb23d38d8
commit cab354ec78
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#include "MeMCore.h"
#include "Arduino.h"
#include "Wire.h"
#include "SoftwareSerial.h"
MeUltrasonicSensor ultraSensor(PORT_3);
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("Distance : ");
Serial.print(ultraSensor.distanceCm() );
Serial.println(" cm");
delay(500); /* the minimal measure interval is 100 milliseconds */
}