#include "Arduino.h" #include "Wire.h" #include "MeMCore.h" #include "SoftwareSerial.h" MeDCMotor _leftMotor(9); MeDCMotor _rightMotor(10); MeUltrasonicSensor ultrasonicSensor(PORT_3); void setup() { // put your setup code here, to run once: _leftMotor.run(0); _rightMotor.run(0); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: if (ultrasonicSensor.distanceCm()>= 20){ Serial.println(ultrasonicSensor.distanceCm()); _leftMotor.run(-100); _rightMotor.run(100); }else{ _leftMotor.stop(); _rightMotor.stop(); delay(1000); _leftMotor.run(100); _rightMotor.run(100); delay(1000); } }