dit is em
Dependencies: mbed
Diff: main.cpp
- Revision:
- 9:daba5ca15c59
- Parent:
- 1:330d2f94f2b6
--- a/main.cpp Wed Feb 15 13:13:32 2017 +0000 +++ b/main.cpp Fri Mar 03 10:28:41 2017 +0000 @@ -1,15 +1,75 @@ #include "mbed.h" - + DigitalOut Motor1 (D13); DigitalOut Motor2 (A0); DigitalOut Motor3 (D12); DigitalOut Motor4 (D11); -DigitalIn Sensor (A1); -DigitalIn dikkeneger(D3); - +AnalogIn Sensor1 (A1); +AnalogIn Sensor2 (A2); +AnalogIn Sensor3 (A3); +AnalogIn Sensor4 (A4); + + + + int main() { while(1) { - if + if ( Sensor1 >= 1) { + Motor1 = 0 ; + Motor2 = 1 ; + Motor3 = 0 ; + Motor4 = 1 ; + wait_ms (2500); + Motor1 = 1 ; + Motor2 = 0 ; + Motor3 = 0 ; + Motor4 = 1 ; + wait_ms (5000); + } + or (Sensor2 >= 1) { + Motor1 = 0 ; + Motor2 = 1 ; + Motor3 = 0 ; + Motor4 = 1 ; + wait_ms (2500); + Motor1 = 1 ; + Motor2 = 0 ; + Motor3 = 0 ; + Motor4 = 1 ; + wait_ms (5000); + } + or (Sensor3 >= 1) { + Motor1 = 0 ; + Motor2 = 1 ; + Motor3 = 0 ; + Motor4 = 1 ; + wait_ms (2500); + Motor1 = 1 ; + Motor2 = 0 ; + Motor3 = 0 ; + Motor4 = 1 ; + wait_ms (5000); + } + or (Sensor4 >= 1) { + Motor1 = 0 ; + Motor2 = 1 ; + Motor3 = 0 ; + Motor4 = 1 ; + wait_ms (2500); + Motor1 = 1 ; + Motor2 = 0 ; + Motor3 = 0 ; + Motor4 = 1 ; + wait_ms (5000); + } + else { + Motor1 = 1 ; + Motor2 = 0 ; + Motor3 = 1 ; + Motor4 = 0 ; + } + } } + \ No newline at end of file