Erick Barrera
/
matriz
matriz
Diff: main.cpp
- Revision:
- 0:d6fe56fdc91c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 13 03:50:54 2018 +0000 @@ -0,0 +1,66 @@ +#include "mbed.h" +#include "b.h" + +Serial a(USBTX,USBRX); +#define uint8_t unsigned char +int Tipofig=0; +int vcol; +uint8_t c=0b00000000; +int grado=0; +uint8_t dat [8]={0,0,0,0,0,0,0,0}; +uint8_t F_t[3]={0b11100000,0b01000000,0}; +uint8_t F_s[3]={0b11000000,0b01100000,0}; +uint8_t F_c[3]={0b11000000,0b11000000,0}; +uint8_t F_l[3]={0b11000000,0b10000000,0b10000000}; +uint8_t F_I[3]={0b10000000,0b10000000,0b10000000}; +int poscol; + + +void borrar() +{ + for(int i=1;i<=8;i++){ + sendSPI(i,0);} +} + +int main() { + a.baud(9600); + sendSPI(0x0c,1); + sendSPI(0x09,0); + sendSPI(0x0A,0x01); + sendSPI(0x0F,1); + wait (0.5); + sendSPI(0x0F,0); + wait (0.5); + sendSPI(0xB,0x7); + borrar(); + while(1){ + Tipofig=a.getc(); + vcol=a.getc(); + grado=a.getc(); + switch(Tipofig) + { + case 1: + giro(F_t,vcol,grado); + break; + case 2: + giro(F_s,vcol,grado); + break; + case 3: + giro(F_c,vcol,grado); + break; + case 4: + giro(F_l,vcol,grado); + break; + case 5: + giro(F_I,vcol,grado); + break; + default: + borrar(); + break; + } + Tipofig=0; + vcol=0; + grado=0; + } + +}