ultrasound sensor

This commit is contained in:
rio.loann 2023-04-24 08:54:32 +02:00
parent 0e8fa620ab
commit 463dc7d85f
2 changed files with 20 additions and 5 deletions

View File

@ -1,7 +1,7 @@
#include <MeMCore.h>
MeDCMotor _leftMoto(9);
MeDCMotor _rightMoto(10);
MeDCMotor _leftMotor(9);
MeDCMotor _rightMotor(10);
void setup()
{
@ -11,11 +11,12 @@ void setup()
void loop()
{
_leftMotor.run(0);
_rightMotor.run(0);
_leftMotor.run(100);
_rightMotor.run(-100);
delay(50);
delay(5000);
_leftMotor.stop();
_rightMotor.stop();
}

View File

@ -0,0 +1,14 @@
#include <MeMCore.h>
MeUltrasonicSensor sensor(3);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(sensor.distanceCm());
}