Isaac Cruz
/
Examen-Equipo03
Equipo 3 - Examen
main.cpp@32:b229ddfa279f, 2019-11-05 (annotated)
- Committer:
- isaacross99
- Date:
- Tue Nov 05 20:44:35 2019 +0000
- Revision:
- 32:b229ddfa279f
- Parent:
- 31:6c36768769ea
Examen Equipo 3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan | 0:7dec7e9ac085 | 1 | #include "mbed.h" |
isaacross99 | 32:b229ddfa279f | 2 | AnalogIn ruido(A2); |
isaacross99 | 32:b229ddfa279f | 3 | DigitalIn boton1(PTC6); |
isaacross99 | 32:b229ddfa279f | 4 | DigitalOut led0(PTC16); |
isaacross99 | 32:b229ddfa279f | 5 | DigitalOut led1(PTC17); |
isaacross99 | 32:b229ddfa279f | 6 | DigitalOut led2(PTB9); |
isaacross99 | 32:b229ddfa279f | 7 | DigitalOut led3(PTA1); |
isaacross99 | 32:b229ddfa279f | 8 | DigitalOut led4(PTB23); |
isaacross99 | 32:b229ddfa279f | 9 | DigitalOut led5(PTA2); |
isaacross99 | 32:b229ddfa279f | 10 | DigitalOut led6(PTC2); |
isaacross99 | 32:b229ddfa279f | 11 | DigitalOut led7(PTC3); |
isaacross99 | 32:b229ddfa279f | 12 | DigitalOut led8(PTC12); |
isaacross99 | 32:b229ddfa279f | 13 | DigitalOut led9(PTC4); |
isaacross99 | 32:b229ddfa279f | 14 | DigitalOut led10(PTD0); |
isaacross99 | 32:b229ddfa279f | 15 | DigitalOut led11(PTD2); |
isaacross99 | 32:b229ddfa279f | 16 | DigitalOut led12(PTD3); |
isaacross99 | 32:b229ddfa279f | 17 | DigitalOut led13(PTD1); |
isaacross99 | 32:b229ddfa279f | 18 | DigitalOut led14(PTE25); |
isaacross99 | 32:b229ddfa279f | 19 | DigitalOut led15(PTE24); |
isaacross99 | 32:b229ddfa279f | 20 | Ticker invocador; |
rgsbuap | 26:29f649949409 | 21 | Serial pc(USBTX,USBRX); |
isaacross99 | 32:b229ddfa279f | 22 | void secuencia(){ |
isaacross99 | 32:b229ddfa279f | 23 | pc.printf("Ejecutando..."); |
isaacross99 | 32:b229ddfa279f | 24 | int i = 0, num = 0, posicion = 0; |
isaacross99 | 32:b229ddfa279f | 25 | num = rand() % 7 + 8; |
isaacross99 | 32:b229ddfa279f | 26 | for(i = 0; i < num; i++){ |
isaacross99 | 32:b229ddfa279f | 27 | led0 = 0; |
isaacross99 | 32:b229ddfa279f | 28 | led1 = 0; |
isaacross99 | 32:b229ddfa279f | 29 | led2 = 0; |
isaacross99 | 32:b229ddfa279f | 30 | led3 = 0; |
isaacross99 | 32:b229ddfa279f | 31 | led4 = 0; |
isaacross99 | 32:b229ddfa279f | 32 | led5 = 0; |
isaacross99 | 32:b229ddfa279f | 33 | led6 = 0; |
isaacross99 | 32:b229ddfa279f | 34 | led7 = 0; |
isaacross99 | 32:b229ddfa279f | 35 | led8 = 0; |
isaacross99 | 32:b229ddfa279f | 36 | led9 = 0; |
isaacross99 | 32:b229ddfa279f | 37 | led10 = 0; |
isaacross99 | 32:b229ddfa279f | 38 | led11 = 0; |
isaacross99 | 32:b229ddfa279f | 39 | led12 = 0; |
isaacross99 | 32:b229ddfa279f | 40 | led13 = 0; |
isaacross99 | 32:b229ddfa279f | 41 | led14 = 0; |
isaacross99 | 32:b229ddfa279f | 42 | led15 = 0; |
isaacross99 | 32:b229ddfa279f | 43 | posicion = rand() % 15 ; |
isaacross99 | 32:b229ddfa279f | 44 | switch(posicion){ |
isaacross99 | 32:b229ddfa279f | 45 | case 0: led0 = 1; |
isaacross99 | 32:b229ddfa279f | 46 | break; |
isaacross99 | 32:b229ddfa279f | 47 | case 1: led1 = 1; |
isaacross99 | 32:b229ddfa279f | 48 | break; |
isaacross99 | 32:b229ddfa279f | 49 | case 2: led2 = 1; |
isaacross99 | 32:b229ddfa279f | 50 | break; |
isaacross99 | 32:b229ddfa279f | 51 | case 3: led3 = 1; |
isaacross99 | 32:b229ddfa279f | 52 | break; |
isaacross99 | 32:b229ddfa279f | 53 | case 4: led4 = 1; |
isaacross99 | 32:b229ddfa279f | 54 | break; |
isaacross99 | 32:b229ddfa279f | 55 | case 5: led5 = 1; |
isaacross99 | 32:b229ddfa279f | 56 | break; |
isaacross99 | 32:b229ddfa279f | 57 | case 6: led6 = 1; |
isaacross99 | 32:b229ddfa279f | 58 | break; |
isaacross99 | 32:b229ddfa279f | 59 | case 7: led7 = 1; |
isaacross99 | 32:b229ddfa279f | 60 | break; |
isaacross99 | 32:b229ddfa279f | 61 | case 8: led8 = 1; |
isaacross99 | 32:b229ddfa279f | 62 | break; |
isaacross99 | 32:b229ddfa279f | 63 | case 9: led9 = 1; |
isaacross99 | 32:b229ddfa279f | 64 | break; |
isaacross99 | 32:b229ddfa279f | 65 | case 10: led10 = 1; |
isaacross99 | 32:b229ddfa279f | 66 | break; |
isaacross99 | 32:b229ddfa279f | 67 | case 11: led11 = 1; |
isaacross99 | 32:b229ddfa279f | 68 | break; |
isaacross99 | 32:b229ddfa279f | 69 | case 12: led12 = 1; |
isaacross99 | 32:b229ddfa279f | 70 | break; |
isaacross99 | 32:b229ddfa279f | 71 | case 13: led13 = 1; |
isaacross99 | 32:b229ddfa279f | 72 | break; |
isaacross99 | 32:b229ddfa279f | 73 | case 14: led14= 1; |
isaacross99 | 32:b229ddfa279f | 74 | break; |
isaacross99 | 32:b229ddfa279f | 75 | case 15: led15= 1; |
isaacross99 | 32:b229ddfa279f | 76 | break; |
isaacross99 | 32:b229ddfa279f | 77 | default: led15 = 1; |
isaacross99 | 32:b229ddfa279f | 78 | } |
isaacross99 | 32:b229ddfa279f | 79 | wait(0.1); |
isaacross99 | 32:b229ddfa279f | 80 | } |
isaacross99 | 32:b229ddfa279f | 81 | led0 = 0; |
isaacross99 | 32:b229ddfa279f | 82 | led1 = 0; |
isaacross99 | 32:b229ddfa279f | 83 | led2 = 0; |
isaacross99 | 32:b229ddfa279f | 84 | led3 = 0; |
isaacross99 | 32:b229ddfa279f | 85 | led4 = 0; |
isaacross99 | 32:b229ddfa279f | 86 | led5 = 0; |
isaacross99 | 32:b229ddfa279f | 87 | led6 = 0; |
isaacross99 | 32:b229ddfa279f | 88 | led7 = 0; |
isaacross99 | 32:b229ddfa279f | 89 | led8 = 0; |
isaacross99 | 32:b229ddfa279f | 90 | led9 = 0; |
isaacross99 | 32:b229ddfa279f | 91 | led10 = 0; |
isaacross99 | 32:b229ddfa279f | 92 | led11 = 0; |
isaacross99 | 32:b229ddfa279f | 93 | led12 = 0; |
isaacross99 | 32:b229ddfa279f | 94 | led13 = 0; |
isaacross99 | 32:b229ddfa279f | 95 | led14 = 0; |
isaacross99 | 32:b229ddfa279f | 96 | led15 = 0; |
isaacross99 | 32:b229ddfa279f | 97 | } |
isaacross99 | 29:734b61eca6df | 98 | int main(){ |
isaacross99 | 32:b229ddfa279f | 99 | led0 = 0; |
isaacross99 | 32:b229ddfa279f | 100 | led1 = 0; |
isaacross99 | 32:b229ddfa279f | 101 | led2 = 0; |
isaacross99 | 32:b229ddfa279f | 102 | led3 = 0; |
isaacross99 | 32:b229ddfa279f | 103 | led4 = 0; |
isaacross99 | 32:b229ddfa279f | 104 | led5 = 0; |
isaacross99 | 32:b229ddfa279f | 105 | led6 = 0; |
isaacross99 | 32:b229ddfa279f | 106 | led7 = 0; |
isaacross99 | 32:b229ddfa279f | 107 | led8 = 0; |
isaacross99 | 32:b229ddfa279f | 108 | led9 = 0; |
isaacross99 | 32:b229ddfa279f | 109 | led10 = 0; |
isaacross99 | 32:b229ddfa279f | 110 | led11 = 0; |
isaacross99 | 32:b229ddfa279f | 111 | led12 = 0; |
isaacross99 | 32:b229ddfa279f | 112 | led13 = 0; |
isaacross99 | 32:b229ddfa279f | 113 | led14 = 0; |
isaacross99 | 32:b229ddfa279f | 114 | led15 = 0; |
isaacross99 | 32:b229ddfa279f | 115 | srand(ruido.read_u16()); |
isaacross99 | 32:b229ddfa279f | 116 | invocador.attach(&secuencia, 10); |
isaacross99 | 32:b229ddfa279f | 117 | secuencia(); |
isaacross99 | 32:b229ddfa279f | 118 | while(1){ |
isaacross99 | 32:b229ddfa279f | 119 | if(!boton1){ |
isaacross99 | 32:b229ddfa279f | 120 | secuencia(); |
isaacross99 | 32:b229ddfa279f | 121 | |
isaacross99 | 32:b229ddfa279f | 122 | } |
isaacross99 | 32:b229ddfa279f | 123 | /*else{ |
isaacross99 | 32:b229ddfa279f | 124 | |
isaacross99 | 32:b229ddfa279f | 125 | }*/ |
isaacross99 | 31:6c36768769ea | 126 | } |
isaacross99 | 32:b229ddfa279f | 127 | } |
isaacross99 | 32:b229ddfa279f | 128 | |
isaacross99 | 32:b229ddfa279f | 129 | //num = rand() % 100; |