4589

Dependencies:   mbed

main.cpp

Committer:
erick_em
Date:
2017-12-11
Revision:
0:c65497674c14

File content as of revision 0:c65497674c14:

#include "mbed.h"

AnalogIn a1(A0);
BusOut M1(D2,D3,D4,D5);
Serial pc(USBTX,USBRX);         //para leer serial y mandarlo a la PC

char pos[4]={0x0A,0x09,0x05,0x06};
char pos2[4]={0x05,0x09,0x0A,0x06};
int i;
int j;
int k;
char l;

int main()
{
    i=0;
    j=0;
    k=0;
    
    
    while (1) 
    {
        
        j=248*a1.read();  
        wait(0.01);
       /* l=l+j;
        j=0;
        j=248*a1.read();  
        wait(0.005);
        l=l+j;
        j=0;
        l=l/2;
        j=l;
       */
       
        printf(" = %d\n",j);
        
       // pc.getc();
        if(k<j)
            {
                M1=pos[i];
                wait(0.003);
                i++;
                k++;
                if(i==4)    {i=0;}
            }
        if(k>j)  
            {
                M1=pos2[i];
                wait(0.003);
                i++;
                k--;
                if(i==4)    {i=0;}
            }     
    }
}