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-18
- Revision:
- 4:bd3bfbaa33bd
- Parent:
- 3:381aaa338447
- Child:
- 5:8e6570af1138
File content as of revision 4:bd3bfbaa33bd:
#include "mbed.h"
DigitalIn K1 (dp25); //Keuzeschakelaar stand 1: Sumo.
DigitalIn K2 (dp16); //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 SLA (dp11); //Sensor links achter.
AnalogIn SRA (dp13); //Sensor rechts achter.
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()
{
float f1 = SLV.read();
float f2 = SRV.read();
float f3 = SLA.read();
float f4 = SRA.read();
int n = 0; //Variabel voor de straight line stand.
MLL = false;
MLR = false;
MRL = false;
MRR = false;
LED = false;
MR = 0;
ML = 0;
while (K1) //Sumo stand.
{
n = 0;
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 links achter. (AANPASSEN)
{
MLL = false;
MLR = false;
MRL = false;
MRR = false;
MR = 0.9;
ML = 1;
wait (0.5); //Duur van de bocht. (AANPASSEN)
}
if (f4 > 0); //Waarde sensor rechts achter. (AANPASSEN)
{
MLL = true;
MLR = false;
MRL = false;
MRR = true;
MR = 1;
ML = 0.9;
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 = !LED;
wait (2);
LED = !LED;
pc.printf("Waarde sensor links voor: %i $$$$$\n", f1); //verstuur de waarde van sensor links voor naar het consol
pc.printf("Waarde sensor rechts voor: %i $$$$$\n", f2); //verstuur de waarde van sensor rechts voor naar het consol
pc.printf("Waarde sensor links achter: %i $$$$$\n", f3); //verstuur de waarde van sensor links achter naar het consol
pc.printf("Waarde sensor rechts achter: %i $$$$$\n", f4); //verstuur de waarde van sensor rechts achter naar het consol
wait (0.5);
}
}