Bluetooth mérés program

Fork of RN42-HelloWorld by Chris Styles

Committer:
szabolor
Date:
Sun Mar 03 11:51:53 2013 +0000
Revision:
2:584102a0bf36
Parent:
1:581f6547e8aa
Child:
3:cd566919776e
Id?z?t?vel EL?G pontosan tartja az ?temet :)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:c1134839fe1a 1 #include "mbed.h"
chris 0:c1134839fe1a 2
szabolor 2:584102a0bf36 3 Timer timer;
szabolor 2:584102a0bf36 4 Ticker meres;
szabolor 1:581f6547e8aa 5 AnalogIn an(p15);
chris 0:c1134839fe1a 6 Serial rn42(p9,p10);
szabolor 1:581f6547e8aa 7 Serial pc(USBTX, USBRX);
chris 0:c1134839fe1a 8 DigitalOut myled(LED1);
szabolor 1:581f6547e8aa 9 int c;
chris 0:c1134839fe1a 10
szabolor 2:584102a0bf36 11 void mfunc() {
szabolor 2:584102a0bf36 12 rn42.printf("%d %f\n",timer.read_ms(), an*3.3);
szabolor 2:584102a0bf36 13 }
szabolor 2:584102a0bf36 14
chris 0:c1134839fe1a 15 int main() {
chris 0:c1134839fe1a 16 rn42.baud(115200);
szabolor 1:581f6547e8aa 17 pc.baud(460800);
szabolor 2:584102a0bf36 18 // mérés elindítása:
szabolor 2:584102a0bf36 19 timer.start();
szabolor 2:584102a0bf36 20 meres.attach(&mfunc, 0.5);
szabolor 2:584102a0bf36 21
szabolor 2:584102a0bf36 22 // biztosítom, hogy kapjon adatot!
chris 0:c1134839fe1a 23 while (1) {
szabolor 1:581f6547e8aa 24 while (rn42.readable()) {
szabolor 1:581f6547e8aa 25 c = rn42.getc();
szabolor 1:581f6547e8aa 26 pc.putc(c);
chris 0:c1134839fe1a 27 }
chris 0:c1134839fe1a 28 }
szabolor 2:584102a0bf36 29 }