Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 1:1c15cf46e1f8, committed 2015-05-28
- Comitter:
- marvin3241
- Date:
- Thu May 28 17:46:05 2015 +0000
- Parent:
- 0:8d2632322439
- Commit message:
- joe
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8d2632322439 -r 1c15cf46e1f8 main.cpp
--- a/main.cpp Thu May 28 07:16:39 2015 +0000
+++ b/main.cpp Thu May 28 17:46:05 2015 +0000
@@ -2,12 +2,10 @@
DigitalIn K1 (dp25); //Keuzeschakelaar stand 1: Sumo.
DigitalIn K2 (dp16); //Keuzeschakelaar stand 2: Straight line.
-DigitalIn K3 (dp26); //Keuzeschakelaar stand 3: Service.
-AnalogIn SA (dp9); //Sensor links voor.
+AnalogIn SA (dp9); //Sensor achter
AnalogIn SRV (dp10); //Sensor rechts voor.
AnalogIn SLV (dp11); //Sensor links achter.
-//AnalogIn SRA (dp13); //Sensor rechts achter.
DigitalOut MLL (dp4); //Draairichting linker motor linksom.
DigitalOut MLR (dp6); //Draairichting linker motor rechtsom.
@@ -18,17 +16,59 @@
PwmOut ML (dp18); //PWM-signaal voor de linker motor.
PwmOut MR (dp2); //PWM-signaal voor de rechter motor.
-Serial pc(USBTX, USBRX); //Gebruik consol.
-
int main()
{
while (1)
{
- if (SLV <= 0.2)
+ if (K1) //sumo stand
{
- LED = !LED;
- wait(1);
+ if (SLV > 0.2 && SRV > 0.2) //als beide sensoren zwart zien. rijdt vooruit.
+ {
+ LED = true;
+ MLL = true;
+ MRR = true;
+ MRL = false;
+ MLR = false;
+ wait (0.1);
+ }
+
+ if (SLV <= 0.2 || SRV <= 0.2) //als 1 van beide sensoren wit ziet
+ {
+ LED = true;
+ MLL = false;//robot rijdt achteruit
+ MRR = false;
+ MLR = true;
+ MRL = true;
+ ML = 1.0;
+ MR = 1.0;
+ wait (1);
+ MLL = true;//robot draait om
+ MRR = false;
+ MRL = true;
+ MLR = false;
+ wait (1);
+
+ }
+
+ }
+ if (K2) //rechte lijn stand
+ {
+ LED = true;
+ wait (2); //even wachten voor het rijden
+ MLL = true;
+ MRR = true;
+ MRL = false;
+ MLR = false;
+ ML = 1.0;
+ MR = 1.0;
+ wait (6);//6 seconden rijden
+ MLL = false;
+ MRR = false;
+ MRL = false;
+ MLR = false;
+ ML = 0.0;
+ MR = 0.0;
+ wait (60);//stoppen en 1 minuut niks doen
}
}
}
-
\ No newline at end of file