Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of matriz by
Revision 2:d70bfc78f62d, committed 2018-10-17
- Comitter:
- Mateom0104
- Date:
- Wed Oct 17 23:23:22 2018 +0000
- Parent:
- 1:899567984090
- Commit message:
- arreglo 1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Oct 16 23:31:40 2018 +0000 +++ b/main.cpp Wed Oct 17 23:23:22 2018 +0000 @@ -4,9 +4,10 @@ Serial pc(SERIAL_TX, SERIAL_RX); SPI deviceM(PA_7,PA_6, PA_5); DigitalOut ssel (PA_4); -InterruptIn girop(PF_1); -InterruptIn posicionmas(PF_0); -InterruptIn posicionmenos(PA_8); +//InterruptIn girop(PF_1); +//InterruptIn posicionmas(PF_0); +//InterruptIn posicionmenos(PA_8); + void Rx_interrupt(); #define uint8_t unsigned char uint8_t screen[8]={0,0,0,0,0,0,0,0}; @@ -240,9 +241,9 @@ } else velocidad=1; - girop.rise(&giros);//interrupcion giro - posicionmenos.rise(&pmenos);//interrupcion posicion menos - posicionmas.rise(&pmas);//interrupcion posicion mas + // girop.rise(&giros);//interrupcion giro + //posicionmenos.rise(&pmenos);//interrupcion posicion menos + //posicionmas.rise(&pmas);//interrupcion posicion mas escribir(); mascara=mascara/2; @@ -253,6 +254,9 @@ /////////////////////////////////////////////////////////////////////////////// int main() { // fucnion principal + pc.baud(9600); + pc.attach(&Rx_interrupt, Serial::RxIrq); + sendSPI(0x0c,1); sendSPI(0x0F,1); wait (1); @@ -265,11 +269,19 @@ while(1){ //pide los datos por el serial - inicio=pc.getc(); - pieza = pc.getc(); - giro=pc.getc(); - posicion=pc.getc(); - fin=pc.getc(); + inicio=60; + pieza=10; + + + while( pieza>6) + { + pieza=rand ()% 16; + pc.printf("%d ",pieza); + } + posicion=3; + giro = 0; + + fin=62; if((inicio==60) && (fin==62)) { @@ -286,4 +298,23 @@ } } } -} \ No newline at end of file +} + + +void Rx_interrupt() { + + char d = pc.getc(); + pc.printf("numero %d\n",d); + + + switch(d) + { + case 97: pmenos(); break; + case 100: pmas(); break; + case 119: giros(); break; + default: pc.printf("Error \n"); + + } + + return; +} \ No newline at end of file