IUT

Dependencies:   mbed Grove_LCD_RGB_Backlight

Committer:
KilianFa
Date:
Thu Jun 27 14:51:31 2019 +0000
Revision:
0:d428df6d37eb
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KilianFa 0:d428df6d37eb 1 #include "mbed.h"
KilianFa 0:d428df6d37eb 2 #include "Grove_LCD_RGB_Backlight.h"
KilianFa 0:d428df6d37eb 3
KilianFa 0:d428df6d37eb 4 Serial mon_module_bluetooth(D14,D15);
KilianFa 0:d428df6d37eb 5 Grove_LCD_RGB_Backlight lcd(D7,D6); //CDA SCL
KilianFa 0:d428df6d37eb 6 DigitalIn FdcIni(D2);
KilianFa 0:d428df6d37eb 7
KilianFa 0:d428df6d37eb 8 int main()
KilianFa 0:d428df6d37eb 9 {
KilianFa 0:d428df6d37eb 10 printf("Coucou\r\n");
KilianFa 0:d428df6d37eb 11 int etat = 0;
KilianFa 0:d428df6d37eb 12 int N_precedent = 0;
KilianFa 0:d428df6d37eb 13 int N = FdcIni.read();
KilianFa 0:d428df6d37eb 14 bool waitIni = false;
KilianFa 0:d428df6d37eb 15 int Moteur = 0;
KilianFa 0:d428df6d37eb 16 lcd.setRGB(100,255,255);
KilianFa 0:d428df6d37eb 17 while(1) {
KilianFa 0:d428df6d37eb 18 N_precedent = N;
KilianFa 0:d428df6d37eb 19 N = FdcIni.read();
KilianFa 0:d428df6d37eb 20
KilianFa 0:d428df6d37eb 21 if (etat == 0) {
KilianFa 0:d428df6d37eb 22 char tab[15];
KilianFa 0:d428df6d37eb 23 lcd.locate(0,0);
KilianFa 0:d428df6d37eb 24 sprintf(tab, "Attente") ; //contenu de tab + val sous le format
KilianFa 0:d428df6d37eb 25 lcd.print(tab) ;
KilianFa 0:d428df6d37eb 26 }
KilianFa 0:d428df6d37eb 27
KilianFa 0:d428df6d37eb 28 if (waitIni && N_precedent == 1 && N == 0) {
KilianFa 0:d428df6d37eb 29 waitIni = false;
KilianFa 0:d428df6d37eb 30 mon_module_bluetooth.printf("i");
KilianFa 0:d428df6d37eb 31 char tab[15];
KilianFa 0:d428df6d37eb 32 lcd.locate(0,0);
KilianFa 0:d428df6d37eb 33 lcd.clear();
KilianFa 0:d428df6d37eb 34 sprintf(tab, "Pret") ; //contenu de tab + val sous le format
KilianFa 0:d428df6d37eb 35 lcd.print(tab) ;
KilianFa 0:d428df6d37eb 36 etat = 2;
KilianFa 0:d428df6d37eb 37 }
KilianFa 0:d428df6d37eb 38
KilianFa 0:d428df6d37eb 39 if (mon_module_bluetooth.readable()) {
KilianFa 0:d428df6d37eb 40 char le_caractere_lu=mon_module_bluetooth.getc();
KilianFa 0:d428df6d37eb 41 printf("%c\r\n", le_caractere_lu);
KilianFa 0:d428df6d37eb 42 // mon_module_bluetooth.printf("2",le_caractere_lu);
KilianFa 0:d428df6d37eb 43
KilianFa 0:d428df6d37eb 44 switch (etat) {
KilianFa 0:d428df6d37eb 45 case 0:
KilianFa 0:d428df6d37eb 46 if(le_caractere_lu == 'a') { // Connected
KilianFa 0:d428df6d37eb 47 mon_module_bluetooth.printf("a");
KilianFa 0:d428df6d37eb 48 etat = 1;
KilianFa 0:d428df6d37eb 49 }
KilianFa 0:d428df6d37eb 50 break;
KilianFa 0:d428df6d37eb 51 case 1:
KilianFa 0:d428df6d37eb 52 if(le_caractere_lu == 'i') { // Connected
KilianFa 0:d428df6d37eb 53 waitIni = true;
KilianFa 0:d428df6d37eb 54 char tab[15];
KilianFa 0:d428df6d37eb 55 lcd.locate(0,0);
KilianFa 0:d428df6d37eb 56 sprintf(tab, "Initialisation...") ; //contenu de tab + val sous le format
KilianFa 0:d428df6d37eb 57 lcd.print(tab) ;
KilianFa 0:d428df6d37eb 58 }
KilianFa 0:d428df6d37eb 59 break;
KilianFa 0:d428df6d37eb 60 case 2:
KilianFa 0:d428df6d37eb 61 if (le_caractere_lu == 'l') { // Gauche
KilianFa 0:d428df6d37eb 62 Moteur = 1;
KilianFa 0:d428df6d37eb 63 }
KilianFa 0:d428df6d37eb 64 if (le_caractere_lu == 'r') { //Droite
KilianFa 0:d428df6d37eb 65 Moteur = 2;
KilianFa 0:d428df6d37eb 66 }
KilianFa 0:d428df6d37eb 67 if (le_caractere_lu == 'n') { // On arrête
KilianFa 0:d428df6d37eb 68 Moteur = 0;
KilianFa 0:d428df6d37eb 69 }
KilianFa 0:d428df6d37eb 70 break;
KilianFa 0:d428df6d37eb 71 }
KilianFa 0:d428df6d37eb 72
KilianFa 0:d428df6d37eb 73 switch (etat) {
KilianFa 0:d428df6d37eb 74 case 0:
KilianFa 0:d428df6d37eb 75
KilianFa 0:d428df6d37eb 76 break;
KilianFa 0:d428df6d37eb 77
KilianFa 0:d428df6d37eb 78 case 1:
KilianFa 0:d428df6d37eb 79
KilianFa 0:d428df6d37eb 80 break;
KilianFa 0:d428df6d37eb 81
KilianFa 0:d428df6d37eb 82 case 2:
KilianFa 0:d428df6d37eb 83 if (Moteur == 0) { // Arrêt
KilianFa 0:d428df6d37eb 84 char tab[15];
KilianFa 0:d428df6d37eb 85 lcd.locate(0,0);
KilianFa 0:d428df6d37eb 86 lcd.clear();
KilianFa 0:d428df6d37eb 87 sprintf(tab, "Pret") ; //contenu de tab + val sous le format
KilianFa 0:d428df6d37eb 88 lcd.print(tab) ;
KilianFa 0:d428df6d37eb 89 } else if (Moteur == 1) { // Gauche
KilianFa 0:d428df6d37eb 90 char tab[15];
KilianFa 0:d428df6d37eb 91 lcd.locate(0,0);
KilianFa 0:d428df6d37eb 92 lcd.clear();
KilianFa 0:d428df6d37eb 93 sprintf(tab, "Gauche") ; //contenu de tab + val sous le format
KilianFa 0:d428df6d37eb 94 lcd.print(tab) ;
KilianFa 0:d428df6d37eb 95 } else { // Droite
KilianFa 0:d428df6d37eb 96 char tab[15];
KilianFa 0:d428df6d37eb 97 lcd.locate(0,0);
KilianFa 0:d428df6d37eb 98 lcd.clear();
KilianFa 0:d428df6d37eb 99 sprintf(tab, "Droite") ; //contenu de tab + val sous le format
KilianFa 0:d428df6d37eb 100 lcd.print(tab) ;
KilianFa 0:d428df6d37eb 101 }
KilianFa 0:d428df6d37eb 102 break;
KilianFa 0:d428df6d37eb 103 }
KilianFa 0:d428df6d37eb 104 }
KilianFa 0:d428df6d37eb 105 }
KilianFa 0:d428df6d37eb 106 }