diff --git a/motion/motion.ino b/motion/motion.ino index 4c068c7..a4018c5 100644 --- a/motion/motion.ino +++ b/motion/motion.ino @@ -1,12 +1,18 @@ -#include MeDCMotor leftRotor(9); MeDCMotor rightRotor(10); +float lSpeed; +float rSpeed; +float duration; void setup() { // put your setup code here, to run once: leftRotor.run(0); rightRotor.run(0); + lSpeed = -100.0; + rSpeed = 100.0; + duration = 1000.0; } @@ -17,4 +23,9 @@ void loop() { delay(duration); leftRotor.stop(); rightRotor.stop(); + delay(duration); + leftRotor.run(0-lSpeed); + rightRotor.run(0-rSpeed); + delay(duration); + } diff --git a/ultrasonicSensor/ultrasonicSensor.ino b/ultrasonicSensor/ultrasonicSensor.ino new file mode 100644 index 0000000..0d4e426 --- /dev/null +++ b/ultrasonicSensor/ultrasonicSensor.ino @@ -0,0 +1,17 @@ +#include + + +MeUltrasonicSensor sensor(3); +float distance; + +void setup() { + // put your setup code here, to run once: + Serial.begin(9600); +} + +void loop() { + // put your main code here, to run repeatedly: + distance = sensor.distanceCm(); + Serial.print(distance); + Serial.print("\n"); +} \ No newline at end of file