Merge branch 'develop' into main
This commit is contained in:
commit
2e47a3ac9b
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include "MeMCore.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "Wire.h"
|
||||||
|
#include "SoftwareSerial.h"
|
||||||
|
|
||||||
|
|
||||||
|
MeDCMotor _leftMotor(9);
|
||||||
|
MeDCMotor _rightMotor(10);
|
||||||
|
MeUltrasonicSensor ultraSensor(PORT_3);
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
Serial.begin(9600);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (ultraSensor.distanceCm()<20){
|
||||||
|
int x=random(-360,360);
|
||||||
|
_leftMotor.run(x);
|
||||||
|
_rightMotor.run(x);
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
_leftMotor.run(200);
|
||||||
|
_rightMotor.run(-200);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue