Faire clignoter les LEDs et relever la mesure du temps d'un tour de rotation.

Dependencies:   mbed HC-05 DHT

Committer:
dani912
Date:
Tue Jun 22 12:32:09 2021 +0000
Revision:
0:4f2b552b676e
projet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dani912 0:4f2b552b676e 1 #include "mbed.h"
dani912 0:4f2b552b676e 2
dani912 0:4f2b552b676e 3 Serial pc(USBTX,USBRX);
dani912 0:4f2b552b676e 4 Serial rn(PA_9,PA_10);
dani912 0:4f2b552b676e 5
dani912 0:4f2b552b676e 6 DigitalOut pc_activity(LED1);
dani912 0:4f2b552b676e 7 DigitalOut uart_activity(LED2);
dani912 0:4f2b552b676e 8 DigitalOut led1(D2);
dani912 0:4f2b552b676e 9 DigitalOut led2(PB_0);
dani912 0:4f2b552b676e 10 DigitalOut led3(PB_1);
dani912 0:4f2b552b676e 11 DigitalOut led4(PF_0);
dani912 0:4f2b552b676e 12 DigitalOut led5(D8);
dani912 0:4f2b552b676e 13 DigitalOut led6(PA_8);
dani912 0:4f2b552b676e 14 DigitalOut led7(PA_11);
dani912 0:4f2b552b676e 15 DigitalOut led8(PB_5);
dani912 0:4f2b552b676e 16
dani912 0:4f2b552b676e 17 int main()
dani912 0:4f2b552b676e 18 {
dani912 0:4f2b552b676e 19
dani912 0:4f2b552b676e 20
dani912 0:4f2b552b676e 21 pc.baud(38400);
dani912 0:4f2b552b676e 22 rn.baud(38400);
dani912 0:4f2b552b676e 23
dani912 0:4f2b552b676e 24 while(1){
dani912 0:4f2b552b676e 25
dani912 0:4f2b552b676e 26 led1 = 1;
dani912 0:4f2b552b676e 27 led2 = 1;
dani912 0:4f2b552b676e 28 wait_us(500);
dani912 0:4f2b552b676e 29 led1 = 0;
dani912 0:4f2b552b676e 30 led2 = 0;
dani912 0:4f2b552b676e 31 led3 = 1;
dani912 0:4f2b552b676e 32 led4 = 1;
dani912 0:4f2b552b676e 33 wait_us(500);
dani912 0:4f2b552b676e 34 led3 = 0;
dani912 0:4f2b552b676e 35 led4 = 0;
dani912 0:4f2b552b676e 36 led5 = 1;
dani912 0:4f2b552b676e 37 led6 = 1;
dani912 0:4f2b552b676e 38 wait_us(500);
dani912 0:4f2b552b676e 39 led5 = 0;
dani912 0:4f2b552b676e 40 led6 = 0;
dani912 0:4f2b552b676e 41 led7 = 1;
dani912 0:4f2b552b676e 42 led8 = 1;
dani912 0:4f2b552b676e 43 wait_us(500);
dani912 0:4f2b552b676e 44 led7 = 0;
dani912 0:4f2b552b676e 45 led8 = 0;
dani912 0:4f2b552b676e 46 /* char y = rn.getc();
dani912 0:4f2b552b676e 47
dani912 0:4f2b552b676e 48 if(y == '4'){
dani912 0:4f2b552b676e 49 ledv = 1;
dani912 0:4f2b552b676e 50 ledr = 0;
dani912 0:4f2b552b676e 51 wait(0.5);
dani912 0:4f2b552b676e 52 }
dani912 0:4f2b552b676e 53 else{
dani912 0:4f2b552b676e 54 ledv = 0;
dani912 0:4f2b552b676e 55 ledr = 1;
dani912 0:4f2b552b676e 56 wait(0.5);
dani912 0:4f2b552b676e 57 } */
dani912 0:4f2b552b676e 58
dani912 0:4f2b552b676e 59
dani912 0:4f2b552b676e 60 if(pc.readable())
dani912 0:4f2b552b676e 61 {
dani912 0:4f2b552b676e 62 rn.putc(pc.getc());
dani912 0:4f2b552b676e 63 pc_activity = !pc_activity;
dani912 0:4f2b552b676e 64
dani912 0:4f2b552b676e 65
dani912 0:4f2b552b676e 66 }
dani912 0:4f2b552b676e 67 if(rn.readable())
dani912 0:4f2b552b676e 68 {
dani912 0:4f2b552b676e 69 pc.putc(rn.getc());
dani912 0:4f2b552b676e 70 uart_activity = !uart_activity;
dani912 0:4f2b552b676e 71 //wait(2);
dani912 0:4f2b552b676e 72 }
dani912 0:4f2b552b676e 73 }
dani912 0:4f2b552b676e 74 }
dani912 0:4f2b552b676e 75
dani912 0:4f2b552b676e 76