Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:9a3e7847a4be
- Child:
- 1:1adf5dfcc7bb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Apr 09 19:26:46 2018 +0000
@@ -0,0 +1,72 @@
+#include <mbed.h>
+
+#include "EncoderCounter.h"
+#include "Controller.h"
+#include "IRSensor.h"
+
+//Sensor I/O:
+
+ AnalogIn lineSensor(PA_0);
+ AnalogIn distance1(PA_1);
+ AnalogIn distance2(PA_4);
+ AnalogIn distance3(PB_0);
+
+ IRSensor irSensorL (distance1);
+ IRSensor irSensorC (distance2);
+ IRSensor irSensorR (distance3);
+
+//Motor I/O:
+ DigitalOut myled(LED1);
+
+ DigitalOut enableMotorDriver(PB_2);
+
+ DigitalIn motorDriverFault(PB_14);
+ DigitalIn motorDriverWarning(PB_15);
+
+ PwmOut pwmLeft(PA_8);
+ PwmOut pwmRight(PA_9);
+
+ EncoderCounter counterLeft(PB_6, PB_7);
+ EncoderCounter counterRight(PA_6, PC_7);
+
+ Controller controller(pwmLeft, pwmRight, counterLeft, counterRight);
+
+int main() {
+
+/* Micromouse Test */
+
+
+ //Sensoren
+ while(1) {
+
+ float distanceL = irSensorL.read();
+ float distanceC = irSensorC.read();
+ float distanceR = irSensorR.read();
+ printf("Rechts: %f Mitte: %f Links: %f Line: %f\n",
+ distanceL, distanceC, distanceR, lineSensor);
+
+ wait(0.5f);
+ }
+
+ //Motoren
+ while(0) {
+
+ controller.setDesiredSpeedLeft(50.0f); //Drehzahl in [rpm]
+ controller.setDesiredSpeedRIght(50.0f);
+ enableMotorDriver = 1; //Schaltet den Leistungstreiber ein
+ while(1) {
+
+ myled =! myled;
+ wait(0.1f); //200 ms
+ }
+
+ }
+
+}
+
+
+
+
+
+
+
\ No newline at end of file
