Utilisation des Leds

Dependencies:   IHM mbed

Committer:
Landry
Date:
Fri Apr 28 12:50:19 2017 +0000
Revision:
0:fcdc465986b0
projet client/serveur

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Landry 0:fcdc465986b0 1 #include "mbed.h"
Landry 0:fcdc465986b0 2 #include "IHM.h"
Landry 0:fcdc465986b0 3 *IHM ihm(PA_11, PA_12);
Landry 0:fcdc465986b0 4 Serial pc(USBTX, USBRX);
Landry 0:fcdc465986b0 5
Landry 0:fcdc465986b0 6 DigitalOut led1(PB_3);
Landry 0:fcdc465986b0 7 DigitalOut led2(PB_7);
Landry 0:fcdc465986b0 8 DigitalOut led3(PB_6);
Landry 0:fcdc465986b0 9 DigitalOut led4(PB_5);
Landry 0:fcdc465986b0 10 DigitalOut led5(PB_3);
Landry 0:fcdc465986b0 11 DigitalOut led6(PB_1);
Landry 0:fcdc465986b0 12 DigitalOut led7(PB_0);
Landry 0:fcdc465986b0 13 DigitalOut led8(PB_2);
Landry 0:fcdc465986b0 14
Landry 0:fcdc465986b0 15
Landry 0:fcdc465986b0 16 int commandeLed = 0x00;
Landry 0:fcdc465986b0 17 char reception[512] = {0};
Landry 0:fcdc465986b0 18 char = mot;
Landry 0:fcdc465986b0 19 int i=0, j=0;
Landry 0:fcdc465986b0 20 int fin=0;
Landry 0:fcdc465986b0 21
Landry 0:fcdc465986b0 22
Landry 0:fcdc465986b0 23 int main() {
Landry 0:fcdc465986b0 24
Landry 0:fcdc465986b0 25 pc.baud(9600);
Landry 0:fcdc465986b0 26
Landry 0:fcdc465986b0 27 while(1) {
Landry 0:fcdc465986b0 28
Landry 0:fcdc465986b0 29 while(fin==0)
Landry 0:fcdc465986b0 30 {
Landry 0:fcdc465986b0 31 if(pc.readable())
Landry 0:fcdc465986b0 32 {
Landry 0:fcdc465986b0 33 mot=pc.getc();
Landry 0:fcdc465986b0 34 reception[j]=mot;
Landry 0:fcdc465986b0 35
Landry 0:fcdc465986b0 36 if(reception[j] == '$') {fin=1};
Landry 0:fcdc465986b0 37
Landry 0:fcdc465986b0 38 j++;
Landry 0:fcdc465986b0 39
Landry 0:fcdc465986b0 40 }
Landry 0:fcdc465986b0 41 }
Landry 0:fcdc465986b0 42
Landry 0:fcdc465986b0 43 ihm.LCD_clear();
Landry 0:fcdc465986b0 44 ihm.LCD_gotoxy(0,0);
Landry 0:fcdc465986b0 45 ihm.LCD_printf("%s", reception);
Landry 0:fcdc465986b0 46 i=0;
Landry 0:fcdc465986b0 47
Landry 0:fcdc465986b0 48 if(reception[i] == 'L')
Landry 0:fcdc465986b0 49 {
Landry 0:fcdc465986b0 50 led8=reception[i+1]-'0';
Landry 0:fcdc465986b0 51 led7=reception[i+2]-'0';
Landry 0:fcdc465986b0 52 led6=reception[i+3]-'0';
Landry 0:fcdc465986b0 53 led5=reception[i+4]-'0';
Landry 0:fcdc465986b0 54 led4=reception[i+5]-'0';
Landry 0:fcdc465986b0 55 led3=reception[i+6]-'0';
Landry 0:fcdc465986b0 56 led2=reception[i+7]-'0';
Landry 0:fcdc465986b0 57 led1=reception[i+8]-'0';
Landry 0:fcdc465986b0 58
Landry 0:fcdc465986b0 59 j=0; i=0;
Landry 0:fcdc465986b0 60 fin=0;
Landry 0:fcdc465986b0 61 }
Landry 0:fcdc465986b0 62
Landry 0:fcdc465986b0 63 }
Landry 0:fcdc465986b0 64
Landry 0:fcdc465986b0 65
Landry 0:fcdc465986b0 66 }
Landry 0:fcdc465986b0 67 }