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
main.cpp
- Committer:
- Mindgyver
- Date:
- 2019-05-24
- Revision:
- 6:1ef44538e16d
- Parent:
- 5:0f73a04481fd
File content as of revision 6:1ef44538e16d:
#include "mbed.h"
//Serial pc(USBTX, USBRX,115200);
Serial BT(PA_9,PA_10,115200); // Depart Bluetooth
//DigitalIn depart(A1); //Depart filaire
DigitalIn interrupteur(D7);
DigitalOut led(LED1);
DigitalOut sens(D8);
PwmOut moteur(D9);
int cas=0;
int main()
{
wait(1);
DigitalOut myled(LED1);
while(1) {
switch (cas) {
case 0: { //Électron immobile
// pc.printf("case 0\n\r");
// Depart Bluetooth
if(BT.readable()) { //Réception d'instruction de l'expérience
if(BT.getc() == 'D') cas = 1; // passage à l'état 1
}
// Depart Filaire
/*if(depart!=0) cas = 1;// passage à l'état 1
*/
break;
}
case 1: { //Électron en mouvement
//pc.printf("cas 2 LANCEMENT\r");
led = 1;
sens = 1;
moteur.pulsewidth_ms(10);
if (interrupteur == 0) {
cas = 2;
}
break;
}
case 2: { //Arrêt de l'électron
//pc.printf("case 2\n\r");
led = 0;
moteur.pulsewidth_ms(0);
break;
}
}
}
}