Bertel verfolgt Linie mit kurzem Programm

Dependencies:   mbed

Committer:
Gsellmann_Sebastian
Date:
Mon Jun 06 09:01:16 2016 +0000
Revision:
0:0a4b051de659
Bertel verfolgt Linie mit k?rzeren Programm

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gsellmann_Sebastian 0:0a4b051de659 1 #include "mbed.h"
Gsellmann_Sebastian 0:0a4b051de659 2
Gsellmann_Sebastian 0:0a4b051de659 3 DigitalOut Von (P2_13); // 12 V ON
Gsellmann_Sebastian 0:0a4b051de659 4 DigitalOut LineON (P2_5); // Line Sensor aktivieren
Gsellmann_Sebastian 0:0a4b051de659 5 DigitalIn ISO1 (P1_9); // ISO1
Gsellmann_Sebastian 0:0a4b051de659 6 DigitalIn ISO2 (P0_16);
Gsellmann_Sebastian 0:0a4b051de659 7 DigitalIn ISO3 (P0_23);
Gsellmann_Sebastian 0:0a4b051de659 8 DigitalIn ISO4 (P0_15);
Gsellmann_Sebastian 0:0a4b051de659 9 DigitalIn ISO5 (P1_3);
Gsellmann_Sebastian 0:0a4b051de659 10
Gsellmann_Sebastian 0:0a4b051de659 11 DigitalOut LedD1 (P1_10);
Gsellmann_Sebastian 0:0a4b051de659 12 DigitalOut LedD2 (P1_11);
Gsellmann_Sebastian 0:0a4b051de659 13 DigitalOut LedD4 (P1_12);
Gsellmann_Sebastian 0:0a4b051de659 14 DigitalOut LedD5 (P1_13);
Gsellmann_Sebastian 0:0a4b051de659 15 DigitalOut LedD6 (P1_14);
Gsellmann_Sebastian 0:0a4b051de659 16 DigitalOut LedD7 (P1_15);
Gsellmann_Sebastian 0:0a4b051de659 17 DigitalOut LedD8 (P1_16);
Gsellmann_Sebastian 0:0a4b051de659 18 DigitalOut LedD9 (P1_17);
Gsellmann_Sebastian 0:0a4b051de659 19 DigitalOut LedD10 (P1_18);
Gsellmann_Sebastian 0:0a4b051de659 20 DigitalOut LedD11 (P2_16);
Gsellmann_Sebastian 0:0a4b051de659 21 DigitalOut LedD12 (P1_20);
Gsellmann_Sebastian 0:0a4b051de659 22 DigitalOut LedD13 (P1_21);
Gsellmann_Sebastian 0:0a4b051de659 23
Gsellmann_Sebastian 0:0a4b051de659 24 PwmOut MotorL_EN(P1_19);
Gsellmann_Sebastian 0:0a4b051de659 25 DigitalOut MotorL_FORWARD(P2_15); // Forwerts
Gsellmann_Sebastian 0:0a4b051de659 26 DigitalOut MotorL_REVERSE(P2_14); // Rückwerts
Gsellmann_Sebastian 0:0a4b051de659 27
Gsellmann_Sebastian 0:0a4b051de659 28 PwmOut MotorR_EN(P2_19);
Gsellmann_Sebastian 0:0a4b051de659 29 DigitalOut MotorR_FORWARD(P2_20);
Gsellmann_Sebastian 0:0a4b051de659 30 DigitalOut MotorR_REVERSE(P2_21);
Gsellmann_Sebastian 0:0a4b051de659 31
Gsellmann_Sebastian 0:0a4b051de659 32 int main() {
Gsellmann_Sebastian 0:0a4b051de659 33 Von=1;
Gsellmann_Sebastian 0:0a4b051de659 34 LineON=1;
Gsellmann_Sebastian 0:0a4b051de659 35 MotorL_EN=1;
Gsellmann_Sebastian 0:0a4b051de659 36 MotorR_EN=1;
Gsellmann_Sebastian 0:0a4b051de659 37
Gsellmann_Sebastian 0:0a4b051de659 38
Gsellmann_Sebastian 0:0a4b051de659 39 while (1) {
Gsellmann_Sebastian 0:0a4b051de659 40 MotorL_FORWARD = 1;
Gsellmann_Sebastian 0:0a4b051de659 41 MotorR_FORWARD = 1;
Gsellmann_Sebastian 0:0a4b051de659 42 MotorL_EN.period_ms (10);
Gsellmann_Sebastian 0:0a4b051de659 43 MotorR_EN.period_ms (10);
Gsellmann_Sebastian 0:0a4b051de659 44 MotorL_EN = 0.3f;
Gsellmann_Sebastian 0:0a4b051de659 45 MotorR_EN.pulsewidth_ms(3);
Gsellmann_Sebastian 0:0a4b051de659 46 MotorR_EN = 0.3f;
Gsellmann_Sebastian 0:0a4b051de659 47 MotorL_EN.pulsewidth_ms(3);
Gsellmann_Sebastian 0:0a4b051de659 48
Gsellmann_Sebastian 0:0a4b051de659 49
Gsellmann_Sebastian 0:0a4b051de659 50 if(ISO1 ==1){
Gsellmann_Sebastian 0:0a4b051de659 51 LedD1 =1;
Gsellmann_Sebastian 0:0a4b051de659 52 MotorL_EN = 1.0f;
Gsellmann_Sebastian 0:0a4b051de659 53 MotorR_EN.pulsewidth_ms(10);
Gsellmann_Sebastian 0:0a4b051de659 54 MotorR_EN = 1.0f;
Gsellmann_Sebastian 0:0a4b051de659 55 MotorL_EN.pulsewidth_ms(10);
Gsellmann_Sebastian 0:0a4b051de659 56
Gsellmann_Sebastian 0:0a4b051de659 57 MotorR_FORWARD=0;
Gsellmann_Sebastian 0:0a4b051de659 58 MotorL_FORWARD=0;
Gsellmann_Sebastian 0:0a4b051de659 59
Gsellmann_Sebastian 0:0a4b051de659 60 MotorR_FORWARD=1;
Gsellmann_Sebastian 0:0a4b051de659 61 MotorL_REVERSE=1;
Gsellmann_Sebastian 0:0a4b051de659 62 }
Gsellmann_Sebastian 0:0a4b051de659 63
Gsellmann_Sebastian 0:0a4b051de659 64 if(ISO4 ==1){
Gsellmann_Sebastian 0:0a4b051de659 65 LedD1 =1;
Gsellmann_Sebastian 0:0a4b051de659 66 MotorL_EN = 1.0f;
Gsellmann_Sebastian 0:0a4b051de659 67 MotorR_EN.pulsewidth_ms(10);
Gsellmann_Sebastian 0:0a4b051de659 68 MotorR_EN = 1.0f;
Gsellmann_Sebastian 0:0a4b051de659 69 MotorL_EN.pulsewidth_ms(10);
Gsellmann_Sebastian 0:0a4b051de659 70
Gsellmann_Sebastian 0:0a4b051de659 71 MotorR_FORWARD=0;
Gsellmann_Sebastian 0:0a4b051de659 72 MotorL_FORWARD=0;
Gsellmann_Sebastian 0:0a4b051de659 73 MotorL_FORWARD=1;
Gsellmann_Sebastian 0:0a4b051de659 74 MotorR_REVERSE=1;
Gsellmann_Sebastian 0:0a4b051de659 75
Gsellmann_Sebastian 0:0a4b051de659 76 }
Gsellmann_Sebastian 0:0a4b051de659 77 wait (0.01);
Gsellmann_Sebastian 0:0a4b051de659 78 MotorL_FORWARD=0;
Gsellmann_Sebastian 0:0a4b051de659 79 MotorR_REVERSE=0;
Gsellmann_Sebastian 0:0a4b051de659 80 MotorR_FORWARD=0;
Gsellmann_Sebastian 0:0a4b051de659 81 MotorL_REVERSE=0;
Gsellmann_Sebastian 0:0a4b051de659 82 }}
Gsellmann_Sebastian 0:0a4b051de659 83
Gsellmann_Sebastian 0:0a4b051de659 84
Gsellmann_Sebastian 0:0a4b051de659 85
Gsellmann_Sebastian 0:0a4b051de659 86