para teban jaja

Dependencies:   mbed

Committer:
through
Date:
Fri Apr 08 21:29:47 2016 +0000
Revision:
0:0026a8de7cf1
compartir;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
through 0:0026a8de7cf1 1 #include "mbed.h"
through 0:0026a8de7cf1 2 Serial pc(USBTX,USBRX);
through 0:0026a8de7cf1 3
through 0:0026a8de7cf1 4 AnalogIn pot(A0);
through 0:0026a8de7cf1 5 DigitalIn smov(D2);
through 0:0026a8de7cf1 6 DigitalIn btnstart(D3);
through 0:0026a8de7cf1 7 DigitalOut b1(D4);
through 0:0026a8de7cf1 8 DigitalOut b2(D5);
through 0:0026a8de7cf1 9 DigitalOut c1(D6);
through 0:0026a8de7cf1 10 DigitalOut c2(D7);
through 0:0026a8de7cf1 11 DigitalOut led(D8);
through 0:0026a8de7cf1 12
through 0:0026a8de7cf1 13 Timer timer;
through 0:0026a8de7cf1 14 Timer timer2;
through 0:0026a8de7cf1 15 int t,conteo2, repetrsen, btn=1, flag, b, conteo;
through 0:0026a8de7cf1 16 float z;
through 0:0026a8de7cf1 17
through 0:0026a8de7cf1 18 int main() {
through 0:0026a8de7cf1 19 //pc.baud(9600);
through 0:0026a8de7cf1 20
through 0:0026a8de7cf1 21 while(1){
through 0:0026a8de7cf1 22 led=1;
through 0:0026a8de7cf1 23
through 0:0026a8de7cf1 24 if(btnstart==0){
through 0:0026a8de7cf1 25 btn=0;
through 0:0026a8de7cf1 26 }
through 0:0026a8de7cf1 27
through 0:0026a8de7cf1 28 if(btn==0){
through 0:0026a8de7cf1 29 t=(pot*1200)/1;
through 0:0026a8de7cf1 30 //pc.printf("tiempo deseado: %d\n", t);
through 0:0026a8de7cf1 31 timer.start();
through 0:0026a8de7cf1 32
through 0:0026a8de7cf1 33 conteo=timer.read();
through 0:0026a8de7cf1 34 //pc.printf("conteo: %d\n", conteo);
through 0:0026a8de7cf1 35
through 0:0026a8de7cf1 36 while(conteo<=t){
through 0:0026a8de7cf1 37
through 0:0026a8de7cf1 38 b1=0;
through 0:0026a8de7cf1 39 b2=1;
through 0:0026a8de7cf1 40 c1=0;
through 0:0026a8de7cf1 41 c2=1;
through 0:0026a8de7cf1 42 wait(0.004);
through 0:0026a8de7cf1 43
through 0:0026a8de7cf1 44 b1=1;
through 0:0026a8de7cf1 45 b2=0;
through 0:0026a8de7cf1 46 c1=0;
through 0:0026a8de7cf1 47 c2=1;
through 0:0026a8de7cf1 48 wait(0.004);
through 0:0026a8de7cf1 49
through 0:0026a8de7cf1 50 b1=1;
through 0:0026a8de7cf1 51 b2=0;
through 0:0026a8de7cf1 52 c1=1;
through 0:0026a8de7cf1 53 c2=0;
through 0:0026a8de7cf1 54 wait(0.004);
through 0:0026a8de7cf1 55
through 0:0026a8de7cf1 56 b1=0;
through 0:0026a8de7cf1 57 b2=1;
through 0:0026a8de7cf1 58 c1=1;
through 0:0026a8de7cf1 59 c2=0;
through 0:0026a8de7cf1 60 wait(0.004);
through 0:0026a8de7cf1 61 conteo=timer.read();
through 0:0026a8de7cf1 62 //pc.printf("conteo: %d\n", conteo);
through 0:0026a8de7cf1 63
through 0:0026a8de7cf1 64 }
through 0:0026a8de7cf1 65 flag=1;
through 0:0026a8de7cf1 66 btn=1;
through 0:0026a8de7cf1 67
through 0:0026a8de7cf1 68 //else{
through 0:0026a8de7cf1 69
through 0:0026a8de7cf1 70 //conteo=0;
through 0:0026a8de7cf1 71 //t=0;
through 0:0026a8de7cf1 72 //}
through 0:0026a8de7cf1 73
through 0:0026a8de7cf1 74
through 0:0026a8de7cf1 75
through 0:0026a8de7cf1 76 for(repetrsen=0; 19; repetrsen++){
through 0:0026a8de7cf1 77 //pc.printf("llego 2da parte");
through 0:0026a8de7cf1 78 flag=1;
through 0:0026a8de7cf1 79 if(smov==1 && flag==1){
through 0:0026a8de7cf1 80 b=1;
through 0:0026a8de7cf1 81
through 0:0026a8de7cf1 82 if(b==1){
through 0:0026a8de7cf1 83 timer2.start();
through 0:0026a8de7cf1 84 conteo2=timer2.read();
through 0:0026a8de7cf1 85 while(conteo2<=5){
through 0:0026a8de7cf1 86 //for(conteo2=0; 120; conteo2++){
through 0:0026a8de7cf1 87
through 0:0026a8de7cf1 88 b1=0;
through 0:0026a8de7cf1 89 b2=1;
through 0:0026a8de7cf1 90 c1=0;
through 0:0026a8de7cf1 91 c2=1;
through 0:0026a8de7cf1 92 wait(0.004);
through 0:0026a8de7cf1 93
through 0:0026a8de7cf1 94 b1=1;
through 0:0026a8de7cf1 95 b2=0;
through 0:0026a8de7cf1 96 c1=0;
through 0:0026a8de7cf1 97 c2=1;
through 0:0026a8de7cf1 98 wait(0.004);
through 0:0026a8de7cf1 99
through 0:0026a8de7cf1 100 b1=1;
through 0:0026a8de7cf1 101 b2=0;
through 0:0026a8de7cf1 102 c1=1;
through 0:0026a8de7cf1 103 c2=0;
through 0:0026a8de7cf1 104 wait(0.004);
through 0:0026a8de7cf1 105
through 0:0026a8de7cf1 106 b1=0;
through 0:0026a8de7cf1 107 b2=1;
through 0:0026a8de7cf1 108 c1=1;
through 0:0026a8de7cf1 109 c2=0;
through 0:0026a8de7cf1 110 wait(0.004);
through 0:0026a8de7cf1 111 conteo2=timer2.read();
through 0:0026a8de7cf1 112 //pc.printf("conteo2: %d\n", conteo2);
through 0:0026a8de7cf1 113 }
through 0:0026a8de7cf1 114 }
through 0:0026a8de7cf1 115 }
through 0:0026a8de7cf1 116 wait(2);
through 0:0026a8de7cf1 117 //btnstart=1;
through 0:0026a8de7cf1 118 //timer.reset();
through 0:0026a8de7cf1 119 }
through 0:0026a8de7cf1 120 }
through 0:0026a8de7cf1 121 /*}else{
through 0:0026a8de7cf1 122 b=0;
through 0:0026a8de7cf1 123 }
through 0:0026a8de7cf1 124 */
through 0:0026a8de7cf1 125
through 0:0026a8de7cf1 126 }
through 0:0026a8de7cf1 127 }