Do NOT modify!

Dependencies:   mbed Servo ServoArm

Fork of PES_Yanick by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Tue Mar 21 13:12:54 2017 +0000
Revision:
2:01e9de508316
Parent:
1:388c915756f5
Child:
4:67d7177c213f
l

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beacon 0:d267b248eff4 1 #include "mbed.h"
beacon 0:d267b248eff4 2 #include "Robot.h"
beacon 0:d267b248eff4 3
beacon 0:d267b248eff4 4 #include <cstdlib>
beacon 0:d267b248eff4 5
beacon 0:d267b248eff4 6 //DistanceSensors related:
beacon 0:d267b248eff4 7 Serial pc(SERIAL_TX, SERIAL_RX);
beacon 0:d267b248eff4 8
beacon 0:d267b248eff4 9 AnalogIn sensorVoltage(PB_1);
beacon 0:d267b248eff4 10 DigitalOut enable(PC_1);
beacon 0:d267b248eff4 11 DigitalOut bit0(PH_1);
beacon 0:d267b248eff4 12 DigitalOut bit1(PC_2);
beacon 0:d267b248eff4 13 DigitalOut bit2(PC_3);
beacon 1:388c915756f5 14
beacon 1:388c915756f5 15 //Leds related:
beacon 1:388c915756f5 16 DigitalOut leds[6] = { PC_8, PC_6, PB_12, PA_7, PC_0, PC_9 };
beacon 0:d267b248eff4 17
beacon 1:388c915756f5 18 //motor related:
beacon 1:388c915756f5 19 PwmOut left(PA_8);
beacon 1:388c915756f5 20 PwmOut right(PA_9);
beacon 0:d267b248eff4 21
beacon 1:388c915756f5 22 DigitalOut powerSignal(PB_2);
beacon 1:388c915756f5 23 DigitalIn errorSignal(PB_14);
beacon 1:388c915756f5 24 DigitalIn overtemperatur(PB_15);
beacon 1:388c915756f5 25
beacon 1:388c915756f5 26 //Farbsensor:
beacon 1:388c915756f5 27 AnalogIn FarbVoltage(A0);
beacon 1:388c915756f5 28
beacon 1:388c915756f5 29 Robot sam( &left, &right, &powerSignal, leds, &FarbVoltage ); //Implement the Farbsensor into the Robot init function!!
beacon 1:388c915756f5 30
beacon 1:388c915756f5 31 void initializeDistanceSensors(){
beacon 0:d267b248eff4 32 for( int ii = 0; ii<6; ++ii) {
beacon 1:388c915756f5 33 sam.sensors[ii].init(&sensorVoltage, &bit0, &bit1, &bit2, ii);
beacon 0:d267b248eff4 34
beacon 1:388c915756f5 35 enable = 1;
beacon 0:d267b248eff4 36 }
beacon 0:d267b248eff4 37 }
beacon 0:d267b248eff4 38
beacon 1:388c915756f5 39 /* */
beacon 1:388c915756f5 40 int main(){
beacon 2:01e9de508316 41 Timer t;
beacon 2:01e9de508316 42 t.start();
beacon 0:d267b248eff4 43
beacon 1:388c915756f5 44 initializeDistanceSensors();
beacon 2:01e9de508316 45 int counter = 0; //counts how many times the robot has turned, before driving
beacon 1:388c915756f5 46
beacon 0:d267b248eff4 47 while( 1 ){
beacon 2:01e9de508316 48 if ( t.read() > TIMEOUT ){
beacon 2:01e9de508316 49 NVIC_SystemReset(); //Resets Sam.
beacon 2:01e9de508316 50 }
beacon 2:01e9de508316 51
beacon 2:01e9de508316 52 sam.search(&counter, &t);
beacon 1:388c915756f5 53 wait( 0.1f );
beacon 0:d267b248eff4 54 }
beacon 0:d267b248eff4 55 return 0;
beacon 1:388c915756f5 56 }