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.
Fork of Versuch21 by
Diff: main.cpp
- Revision:
- 1:6ef5bc60e69c
- Parent:
- 0:b886f13e4ac6
- Child:
- 2:efa9a78591da
diff -r b886f13e4ac6 -r 6ef5bc60e69c main.cpp
--- a/main.cpp Sun Apr 22 16:14:54 2018 +0000
+++ b/main.cpp Mon Apr 23 16:18:41 2018 +0000
@@ -1,5 +1,4 @@
#include <mbed.h>
-
#include "EncoderCounter.h"
#include "Controller.h"
#include "IRSensorG.h"
@@ -8,7 +7,7 @@
#include "IRSensorZ.h"
#include "Spurhaltung.h"
#include "LHR.h"
-#include <Motion.h>
+#include "Motion.h"
//Motorbefehle von LHR
int D, sl, sr;
@@ -22,7 +21,7 @@
AnalogIn sensorValue5(PA_4); // Seitlicher Sensor rechts
AnalogIn sensorValue6(PB_0); // Helligkeitssensor
DigitalOut myled(LED1); // LED 1
-DigitalIn button(PC_13); // Startknopf
+DigitalIn button(USER_BUTTON); // Startknopf
DigitalOut power_5v(PC_4); // 5V auf Sensoren, geschalten
DigitalOut enable(PC_1);
@@ -49,41 +48,28 @@
IRSensorK Sensor5(sensorValue5);
// Helligkeitssensor aufrufen
IRSensorZ Sensor6(sensorValue6);
-//Spurhaltung aufrufen
-//Spurhaltung x(sensorValue2, sensorValue3);
-//LHR
-//LHR LHR(Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6);
-// Motion
-//Motion motion(D, counterLeft, counterRight, controller);
int main()
{
power_5v = 1; // Einschalten 5V Speisung der Sensoren
enable = 1;
enableMotorDriver = 1; //Schaltet den Leistungstreiber ein
- /* while (Sensor1.read() == 0){
- controller.setDesiredSpeedLeft(150.0f); //Drehzahl in [rpm]
- controller.setDesiredSpeedRight(-150.0f);
- printf("Sensor1: %d", Sensor1.read());
- }*/
LHR LHR(Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6);
Spurhaltung spurhaltung(Sensor2, Sensor3);
- Motion motion(counterLeft, counterRight, controller, spurhaltung);
+ Motion motion(counterLeft, counterRight, controller, spurhaltung, Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6);
- D = 2;
+
if(button==1) {
while (1) {
D = LHR.moving();
- //D = 2;
- //printf("D: %d\n", D);
- //printf("Distanz rechts: %d\r\n", Sensor3.read());
- sl = spurhaltung.speedr();
- printf("Status: %d\r\n", button);
- sr = spurhaltung.speedl();
+ //sl = spurhaltung.speedr();
+ //printf("Status: %d\r\n", button);
+ //sr = spurhaltung.speedl();
motion.switching(D);
+
}
}
}
\ No newline at end of file
