Function to measure a distance with an ultrasonic sensor
This commit is contained in:
parent
66c4cd0ab4
commit
4453fbea1a
|
|
@ -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());
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue