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
TechMoveDXC.cpp
- Committer:
- IKn0Ww
- Date:
- 2015-04-21
- Revision:
- 5:8e6570af1138
- Parent:
- 4:bd3bfbaa33bd
File content as of revision 5:8e6570af1138:
#include "mbed.h"
DigitalIn K1 (dp25); //Keuzeschakelaar stand 1: Sumo.
DigitalIn K2 (dp17); //Keuzeschakelaar stand 2: Straight line.
DigitalIn K3 (dp26); //Keuzeschakelaar stand 3: Service.
AnalogIn SLV (dp9); //Sensor links voor.
AnalogIn SRV (dp10); //Sensor rechts voor.
AnalogIn SA (dp11); //Sensor achter.
AnalogIn SML (dp4); //Sensor motor links.
AnalogIn SMR (dp13); //Sensor motor rechts.
DigitalOut MLL (dp5); //Draairichting linker motor linksom.
DigitalOut MLR (dp6); //Draairichting linker motor rechtsom.
DigitalOut MRL (dp1); //Draairichting rechter motor linksom.
DigitalOut MRR (dp24); //Draairichting rechter motor rechtsom.
DigitalOut LED (dp28); //Indicatie LED.
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()
{
int n = 0; //Variabel voor de straight line stand.
float f1;
float f2;
float f3;
float f4;
float f5;
MLL = false;
MLR = false;
MRL = false;
MRR = false;
LED = false;
MR = 0;
ML = 0;
while (1)
{
while (K1) //Sumo stand.
{
n = 0;
f1 = SLV.read();
f2 = SRV.read();
f3 = SA.read();
f4 = SML.read();
f5 = SMR.read();
LED = true;
MLL = true;
MLR = false;
MRL = false;
MRR = true;
MR = 0.8;
ML = 0.8;
if (f1 > 0); //Waarde sensor links voor. (AANPASSEN)
{
MLL = true;
MLR = false;
MRL = true;
MRR = false;
MR = 0.8;
ML = 0.5;
wait (1); //Duur van de bocht. (AANPASSEN)
}
if (f2 > 0); //Waarde sensor rechts voor. (AANPASSEN)
{
MLL = false;
MLR = true;
MRL = false;
MRR = true;
MR = 0.5;
ML = 0.8;
wait (1); //Duur van de bocht. (AANPASSEN)
}
if (f3 > 0); //Waarde sensor achter. (AANPASSEN)
{
MLL = true;
MLR = false;
MRL = false;
MRR = true;
MR = 1;
ML = 1;
wait (0.5); //Duur van de bocht. (AANPASSEN)
}
if (f4 > 0); //Waarde sensor motor links. (AANPASSEN)
{
MLL = true;
MLR = false;
MRL = false;
MRR = true;
MR = 0.5;
ML = 0.5;
wait (0.5); //Duur van de bocht. (AANPASSEN)
}
if (f5 > 0); //Waarde sensor motor rechts. (AANPASSEN)
{
MLL = true;
MLR = false;
MRL = false;
MRR = true;
MR = 0.5;
ML = 0.5;
wait (0.5); //Duur van de bocht. (AANPASSEN)
}
}
while (K2) //Straight line stand.
{
LED = !LED;
n += 1;
if (n == 6)
{
MLL = true;
MLR = false;
MRL = false;
MRR = true;
MR = 1.0;
ML = 1.0;
wait (0); //Tijd van het rijden. (AANPASSEN)
MLL = false;
MLR = false;
MRL = false;
MRR = false;
MR = 0;
ML = 0;
}
wait (0.5);
}
while (K3) //Service stand.
{
n = 0;
LED = false;
wait (10);
LED = true;
float f1 = SLV.read();
float f2 = SRV.read();
float f3 = SA.read();
pc.printf("Waarde sensor links voor: %.6f\n", f1); //verstuur de waarde van sensor links voor naar het consol
pc.printf("Waarde sensor rechts voor: %.6f\n", f2); //verstuur de waarde van sensor rechts voor naar het consol
pc.printf("Waarde sensor links achter: %.6f\n", f3); //verstuur de waarde van sensor achter naar het consol
wait (0.5);
}
}
}