Library koji prima znakove preko bluetooth modula i prema tome izvrsava zadane radnje
Revision 0:3276e35a8063, committed 2020-11-26
- Comitter:
- leleracic
- Date:
- Thu Nov 26 16:40:57 2020 +0000
- Commit message:
- Citanje znaka
Changed in this revision
Citanjeznaka.cpp | Show annotated file Show diff for this revision Revisions of this file |
Citanjeznaka.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 3276e35a8063 Citanjeznaka.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Citanjeznaka.cpp Thu Nov 26 16:40:57 2020 +0000 @@ -0,0 +1,47 @@ +#include "Citanjeznaka.h" +#include "potenciometar.h" + +Serial bluetooth(PA_9, PA_10); +Serial pc(USBTX,USBRX); + +char rx; +int start=0; + +Ticker flipper; + +void flip() { // flip function + kreni = !kreni; +} + +int Citanjeznaka(void){ + if(bluetooth.readable()) { + rx = bluetooth.getc(); + //pc.printf("%c\n\r",rx); + if(rx == 'P'){ + kreni=1; + flipper.attach(&flip, 0.2); + } + if(rx == 'N') { + flipper.detach(); + kreni=1; + stop=0; + start=0; + buzzer=0.5; + buzzer.period(0.0028); + } + if(rx == 'R') { + flipper.detach(); + kreni=0; + stop=1; + start=1; + } + if(rx=='G'){ + flipper.detach(); + kreni=0; + stop=0; + start=0; + buzzer=0.0; + } + } + return start; +} \ No newline at end of file
diff -r 000000000000 -r 3276e35a8063 Citanjeznaka.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Citanjeznaka.h Thu Nov 26 16:40:57 2020 +0000 @@ -0,0 +1,8 @@ +#ifndef CITANJEZNAKA_H +#define CITANJEZNAKA_H +#include "mbed.h" +extern Serial pc; +extern Serial bluetooth; +extern int start; +int Citanjeznaka(void); +#endif