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
Diff: main.cpp
- Revision:
- 3:43dac789686d
- Parent:
- 2:c46e5c0f09dc
- Child:
- 4:3bff5791d6d3
--- a/main.cpp Fri May 24 11:23:38 2019 +0000
+++ b/main.cpp Fri May 24 14:12:15 2019 +0000
@@ -15,43 +15,60 @@
int main()
{
- wait(1);
+ int connect = 0;
+ wait_ms(1000);
DigitalOut myled(LED1);
- BT.printf("$$$");
- wait(1);
- BT.printf("C\r");
-
- while(1) {
-
- switch (cas) {
- case 0: {
- pc.printf("case 0\n\r");
- if(BT.readable()){
- if(BT.getc() == 'L') cas = 1;
- }
- break;
-
- }
+
+ BT.printf("$$$"); //Passage en mode commande
+ wait_ms(10000); //
+ BT.printf("C\r"); //Demande de connexion
+ wait_ms(1000); //
+
+ /*while(connect != 1) {
+ BT.printf("$$$"); //Passage en mode commande
+ wait_ms(1000); //
+ BT.printf("C\r"); //Demande de connexion
+ wait_ms(1000); //
+ BT.printf("O"); //Test de connection
+ if (BT.readable()) { //
+ if (BT.getc() == 'O') { //Réponse de l'expérience reçue ?
+ connect = 1;
+ BT.printf("---\r");
+ }
+ }
+ } */
+
+ while(1) {
- case 1: {
- pc.printf("cas 2 LANCEMENT\r");
- led = 1;
- sens = 1;
- moteur.pulsewidth_ms(10);
- if (interrupteur == 0) {
- cas = 2;
+ switch (cas) {
+ case 0: { //Électron immobile
+ pc.printf("case 0\n\r");
+ if(BT.readable()) { //Réception d'instruction de l'expérience
+ if(BT.getc() == 'L') cas = 1; // passage à l'état 1
+ }
+ break;
+
}
- break;
- }
-
- case 2: {
- pc.printf("case 2\n\r");
- led = 0;
- moteur.pulsewidth_ms(0);
- 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;
+
+ }
}
}
}
-}