Dependencies:   Farbsensor IRSensorLib PID_Control Servo mbed PixyLib

Committer:
ZHAW_Prometheus
Date:
Wed May 10 08:59:22 2017 +0000
Revision:
0:422088ad7fc5
Child:
1:5c44e2462a8b
Prom_Roebi_0.1

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 0:422088ad7fc5 7
ZHAW_Prometheus 0:422088ad7fc5 8 /**
ZHAW_Prometheus 0:422088ad7fc5 9 *Aus- und Eingänge initialisieren
ZHAW_Prometheus 0:422088ad7fc5 10 */
ZHAW_Prometheus 0:422088ad7fc5 11 //IRSensoren
ZHAW_Prometheus 0:422088ad7fc5 12 DigitalOut enable(PC_1);
ZHAW_Prometheus 0:422088ad7fc5 13 DigitalOut bit0(PH_1);
ZHAW_Prometheus 0:422088ad7fc5 14 DigitalOut bit1(PC_2);
ZHAW_Prometheus 0:422088ad7fc5 15 DigitalOut bit2(PC_3);
ZHAW_Prometheus 0:422088ad7fc5 16 AnalogIn distance(PB_1);
ZHAW_Prometheus 0:422088ad7fc5 17 //Motoren
ZHAW_Prometheus 0:422088ad7fc5 18 DigitalOut enableMotorDriver(PB_2);
ZHAW_Prometheus 0:422088ad7fc5 19 PwmOut pwmLeft(PA_8);
ZHAW_Prometheus 0:422088ad7fc5 20 PwmOut pwmRight(PA_9);
ZHAW_Prometheus 0:422088ad7fc5 21 //LED's
ZHAW_Prometheus 0:422088ad7fc5 22 DigitalOut led0(PC_8);
ZHAW_Prometheus 0:422088ad7fc5 23 DigitalOut led1(PC_6);
ZHAW_Prometheus 0:422088ad7fc5 24 DigitalOut led5(PC_9);
ZHAW_Prometheus 0:422088ad7fc5 25 DigitalOut led3(PC_7);
ZHAW_Prometheus 0:422088ad7fc5 26 //Farbauswertung
ZHAW_Prometheus 0:422088ad7fc5 27 AnalogIn SensorG(PA_0);
ZHAW_Prometheus 0:422088ad7fc5 28 AnalogIn SensorR(PA_1);
ZHAW_Prometheus 0:422088ad7fc5 29 Servo ServoAusw(PB_7);
ZHAW_Prometheus 0:422088ad7fc5 30 //Serielle Ausgabe
ZHAW_Prometheus 0:422088ad7fc5 31 Serial pc(SERIAL_TX,SERIAL_RX);
ZHAW_Prometheus 0:422088ad7fc5 32
ZHAW_Prometheus 0:422088ad7fc5 33 Farbauswertung farbauswertung(&SensorG, &SensorR, &ServoAusw);
ZHAW_Prometheus 0:422088ad7fc5 34
ZHAW_Prometheus 0:422088ad7fc5 35 int main()
ZHAW_Prometheus 0:422088ad7fc5 36 {
ZHAW_Prometheus 0:422088ad7fc5 37 farbauswertung.setSerialOutput(&pc);
ZHAW_Prometheus 0:422088ad7fc5 38
ZHAW_Prometheus 0:422088ad7fc5 39 Ticker farbe;
ZHAW_Prometheus 0:422088ad7fc5 40 farbe.attach(&farbauswertung, &Farbauswertung::auswertung, 0.5);
ZHAW_Prometheus 0:422088ad7fc5 41
ZHAW_Prometheus 0:422088ad7fc5 42 while (1) {
ZHAW_Prometheus 0:422088ad7fc5 43
ZHAW_Prometheus 0:422088ad7fc5 44 wait(0.2);
ZHAW_Prometheus 0:422088ad7fc5 45 }
ZHAW_Prometheus 0:422088ad7fc5 46 }