Fährt wenn der Sensor Lichtsignale rückempfängt, die er gesendet hat
Dependencies: mbed
Uebung1.cpp@0:b4f9731c4fad, 2016-06-08 (annotated)
- Committer:
- marcusrus
- Date:
- Wed Jun 08 11:31:26 2016 +0000
- Revision:
- 0:b4f9731c4fad
LineSensorFahrt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcusrus | 0:b4f9731c4fad | 1 | #include "mbed.h" |
marcusrus | 0:b4f9731c4fad | 2 | |
marcusrus | 0:b4f9731c4fad | 3 | DigitalOut Von (P2_13); // 12 V ON |
marcusrus | 0:b4f9731c4fad | 4 | DigitalOut LineON (P2_5); // Line Sensor aktivieren |
marcusrus | 0:b4f9731c4fad | 5 | DigitalIn ISO1 (P1_9); // ISO1 |
marcusrus | 0:b4f9731c4fad | 6 | DigitalIn ISO2 (P0_16); |
marcusrus | 0:b4f9731c4fad | 7 | DigitalIn ISO3 (P0_23); |
marcusrus | 0:b4f9731c4fad | 8 | DigitalIn ISO4 (P0_15); |
marcusrus | 0:b4f9731c4fad | 9 | DigitalIn ISO5 (P1_3); // OSI5 |
marcusrus | 0:b4f9731c4fad | 10 | |
marcusrus | 0:b4f9731c4fad | 11 | DigitalOut LedD1 (P1_10); |
marcusrus | 0:b4f9731c4fad | 12 | DigitalOut LedD2 (P1_11); |
marcusrus | 0:b4f9731c4fad | 13 | DigitalOut LedD4 (P1_12); |
marcusrus | 0:b4f9731c4fad | 14 | DigitalOut LedD5 (P1_13); |
marcusrus | 0:b4f9731c4fad | 15 | DigitalOut LedD6 (P1_14); |
marcusrus | 0:b4f9731c4fad | 16 | DigitalOut LedD7 (P1_15); |
marcusrus | 0:b4f9731c4fad | 17 | DigitalOut LedD8 (P1_16); |
marcusrus | 0:b4f9731c4fad | 18 | DigitalOut LedD9 (P1_17); |
marcusrus | 0:b4f9731c4fad | 19 | DigitalOut LedD10 (P1_18); |
marcusrus | 0:b4f9731c4fad | 20 | DigitalOut LedD11 (P2_16); |
marcusrus | 0:b4f9731c4fad | 21 | DigitalOut LedD12 (P1_20); |
marcusrus | 0:b4f9731c4fad | 22 | DigitalOut LedD13 (P1_21); |
marcusrus | 0:b4f9731c4fad | 23 | |
marcusrus | 0:b4f9731c4fad | 24 | DigitalOut MotorL_EN(P1_19); // Enable |
marcusrus | 0:b4f9731c4fad | 25 | DigitalOut MotorL_FORWARD(P2_14); // Forwärts |
marcusrus | 0:b4f9731c4fad | 26 | DigitalOut MotorL_REVERSE(P2_15); // Rückwärts |
marcusrus | 0:b4f9731c4fad | 27 | |
marcusrus | 0:b4f9731c4fad | 28 | DigitalOut MotorR_EN(P2_19); //Die Leitung führt zum Pin PO_21 am Prozessor |
marcusrus | 0:b4f9731c4fad | 29 | DigitalOut MotorR_FORWARD(P2_21); //Die Leitung führt zum Pin P1_3 am Prozessor |
marcusrus | 0:b4f9731c4fad | 30 | DigitalOut MotorR_REVERSE(P2_20); |
marcusrus | 0:b4f9731c4fad | 31 | |
marcusrus | 0:b4f9731c4fad | 32 | |
marcusrus | 0:b4f9731c4fad | 33 | int main() |
marcusrus | 0:b4f9731c4fad | 34 | { |
marcusrus | 0:b4f9731c4fad | 35 | |
marcusrus | 0:b4f9731c4fad | 36 | do |
marcusrus | 0:b4f9731c4fad | 37 | { |
marcusrus | 0:b4f9731c4fad | 38 | LineON=1; |
marcusrus | 0:b4f9731c4fad | 39 | Von=1; |
marcusrus | 0:b4f9731c4fad | 40 | MotorR_EN=MotorL_EN=1; |
marcusrus | 0:b4f9731c4fad | 41 | |
marcusrus | 0:b4f9731c4fad | 42 | if(ISO1==0) |
marcusrus | 0:b4f9731c4fad | 43 | { |
marcusrus | 0:b4f9731c4fad | 44 | LedD1=LedD2=LedD4=LedD5=LedD6=LedD7=LedD8=LedD9=LedD10=LedD11=LedD12=LedD13=0; |
marcusrus | 0:b4f9731c4fad | 45 | MotorR_FORWARD=MotorL_FORWARD=1; |
marcusrus | 0:b4f9731c4fad | 46 | } |
marcusrus | 0:b4f9731c4fad | 47 | else |
marcusrus | 0:b4f9731c4fad | 48 | { |
marcusrus | 0:b4f9731c4fad | 49 | LedD1=LedD2=LedD4=LedD5=LedD6=LedD7=LedD8=LedD9=LedD10=LedD11=LedD12=LedD13=1; |
marcusrus | 0:b4f9731c4fad | 50 | MotorR_FORWARD=MotorL_FORWARD=0; |
marcusrus | 0:b4f9731c4fad | 51 | } |
marcusrus | 0:b4f9731c4fad | 52 | }while(1==1); |
marcusrus | 0:b4f9731c4fad | 53 | } |