Prom_Roebi_0.1

Dependencies:   Farbsensor IRSensorLib PID_Control Servo mbed PixyLib

Committer:
schuema4
Date:
Sat May 13 12:52:51 2017 +0000
Revision:
3:017c85c4b14b
Parent:
2:dea0bab5e45c
Child:
5:4b409c37e81f
Child:
7:5949f408b6da
stand 13.05.17_14:52

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ZHAW_Prometheus 0:422088ad7fc5 1 #include "mbed.h"
ZHAW_Prometheus 0:422088ad7fc5 2 #include "cstdlib"
ZHAW_Prometheus 0:422088ad7fc5 3 #include "IRSensor.h"
ZHAW_Prometheus 0:422088ad7fc5 4 #include "Servo.h"
ZHAW_Prometheus 0:422088ad7fc5 5 #include "Pixy.h"
ZHAW_Prometheus 0:422088ad7fc5 6 #include "Farbauswertung.h"
ZHAW_Prometheus 1:5c44e2462a8b 7 #include "Fahren.h"
ZHAW_Prometheus 1:5c44e2462a8b 8 #include "liftAnsteuerung.h"
ZHAW_Prometheus 0:422088ad7fc5 9
ZHAW_Prometheus 0:422088ad7fc5 10 /**
ZHAW_Prometheus 0:422088ad7fc5 11 *Aus- und Eingänge initialisieren
ZHAW_Prometheus 0:422088ad7fc5 12 */
ZHAW_Prometheus 1:5c44e2462a8b 13 //Button
ZHAW_Prometheus 1:5c44e2462a8b 14 DigitalIn usrButton(USER_BUTTON);
ZHAW_Prometheus 0:422088ad7fc5 15 //IRSensoren
ZHAW_Prometheus 0:422088ad7fc5 16 DigitalOut enable(PC_1);
ZHAW_Prometheus 0:422088ad7fc5 17 DigitalOut bit0(PH_1);
ZHAW_Prometheus 0:422088ad7fc5 18 DigitalOut bit1(PC_2);
ZHAW_Prometheus 0:422088ad7fc5 19 DigitalOut bit2(PC_3);
ZHAW_Prometheus 0:422088ad7fc5 20 AnalogIn distance(PB_1);
ZHAW_Prometheus 0:422088ad7fc5 21 //Motoren
ZHAW_Prometheus 0:422088ad7fc5 22 DigitalOut enableMotorDriver(PB_2);
ZHAW_Prometheus 0:422088ad7fc5 23 PwmOut pwmLeft(PA_8);
ZHAW_Prometheus 0:422088ad7fc5 24 PwmOut pwmRight(PA_9);
ZHAW_Prometheus 0:422088ad7fc5 25 //LED's
ZHAW_Prometheus 0:422088ad7fc5 26 DigitalOut led0(PC_8);
ZHAW_Prometheus 0:422088ad7fc5 27 DigitalOut led1(PC_6);
ZHAW_Prometheus 0:422088ad7fc5 28 DigitalOut led5(PC_9);
ZHAW_Prometheus 1:5c44e2462a8b 29 DigitalOut led3(PA_7);
ZHAW_Prometheus 0:422088ad7fc5 30 //Farbauswertung
ZHAW_Prometheus 0:422088ad7fc5 31 AnalogIn SensorG(PA_0);
ZHAW_Prometheus 0:422088ad7fc5 32 AnalogIn SensorR(PA_1);
ZHAW_Prometheus 0:422088ad7fc5 33 Servo ServoAusw(PB_7);
ZHAW_Prometheus 1:5c44e2462a8b 34 Servo ServoFoerder(PC_7);
ZHAW_Prometheus 1:5c44e2462a8b 35 //Lift
ZHAW_Prometheus 1:5c44e2462a8b 36 Servo ServoLift(PA_6);
ZHAW_Prometheus 1:5c44e2462a8b 37
ZHAW_Prometheus 0:422088ad7fc5 38 //Serielle Ausgabe
ZHAW_Prometheus 0:422088ad7fc5 39 Serial pc(SERIAL_TX,SERIAL_RX);
ZHAW_Prometheus 0:422088ad7fc5 40
ZHAW_Prometheus 1:5c44e2462a8b 41 Farbauswertung farbauswertung(&SensorG, &SensorR, &ServoAusw);
ZHAW_Prometheus 1:5c44e2462a8b 42 Fahren fahren(&enable, &bit0, &bit1, &bit2, &distance, &enableMotorDriver, &pwmLeft, &pwmRight);
ZHAW_Prometheus 2:dea0bab5e45c 43 LiftAnsteuerung lift(30, 5, &ServoLift);
ZHAW_Prometheus 0:422088ad7fc5 44
ZHAW_Prometheus 0:422088ad7fc5 45 int main()
ZHAW_Prometheus 0:422088ad7fc5 46 {
ZHAW_Prometheus 0:422088ad7fc5 47 farbauswertung.setSerialOutput(&pc);
ZHAW_Prometheus 1:5c44e2462a8b 48 fahren.setSerialOutput(&pc);
ZHAW_Prometheus 1:5c44e2462a8b 49
ZHAW_Prometheus 1:5c44e2462a8b 50 ServoLift = 1.2f; //1.2
ZHAW_Prometheus 1:5c44e2462a8b 51 ServoFoerder = 0.1f; //0.1
ZHAW_Prometheus 1:5c44e2462a8b 52
ZHAW_Prometheus 1:5c44e2462a8b 53 fahren.fahrInit();
ZHAW_Prometheus 0:422088ad7fc5 54
ZHAW_Prometheus 0:422088ad7fc5 55 Ticker farbe;
schuema4 3:017c85c4b14b 56 farbe.attach(&farbauswertung, &Farbauswertung::auswertung, 0.01);
ZHAW_Prometheus 0:422088ad7fc5 57
ZHAW_Prometheus 1:5c44e2462a8b 58 Ticker drive;
schuema4 3:017c85c4b14b 59 drive.attach(&fahren, &Fahren::fahrRutine, 0.01);
ZHAW_Prometheus 1:5c44e2462a8b 60
schuema4 3:017c85c4b14b 61 // Ticker elevator;
schuema4 3:017c85c4b14b 62 // elevator.attach(&lift, &LiftAnsteuerung::steuerung, 0.5);
ZHAW_Prometheus 1:5c44e2462a8b 63
ZHAW_Prometheus 0:422088ad7fc5 64 while (1) {
ZHAW_Prometheus 0:422088ad7fc5 65
schuema4 3:017c85c4b14b 66 wait(0.001);
ZHAW_Prometheus 0:422088ad7fc5 67 }
ZHAW_Prometheus 0:422088ad7fc5 68 }