![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dd
Dependencies: xtoff2 RF24Network mbed
Fork of xtoff3 by
main.cpp@6:6a82110ff393, 2018-02-19 (annotated)
- Committer:
- pietor
- Date:
- Mon Feb 19 14:44:11 2018 +0000
- Revision:
- 6:6a82110ff393
- Parent:
- 4:7ebc3b421306
- Child:
- 7:8515f205483b
Ontvanger
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pietor | 4:7ebc3b421306 | 1 | /** |
pietor | 4:7ebc3b421306 | 2 | Main.cpp |
pietor | 4:7ebc3b421306 | 3 | Purpose: main class |
pietor | 4:7ebc3b421306 | 4 | |
pietor | 4:7ebc3b421306 | 5 | @author Pieter Berteloot |
pietor | 4:7ebc3b421306 | 6 | */ |
akashvibhute | 0:3982c0e9eda1 | 7 | #include "mbed.h" |
pietor | 4:7ebc3b421306 | 8 | #include "Ontvanger.h" |
pietor | 4:7ebc3b421306 | 9 | |
pietor | 4:7ebc3b421306 | 10 | DigitalOut myled1(LED1); |
pietor | 4:7ebc3b421306 | 11 | DigitalOut myled2(LED2); |
pietor | 4:7ebc3b421306 | 12 | DigitalOut myled3(LED3); |
pietor | 4:7ebc3b421306 | 13 | DigitalOut myled4(LED4); |
akashvibhute | 0:3982c0e9eda1 | 14 | |
akashvibhute | 0:3982c0e9eda1 | 15 | Serial pc(USBTX, USBRX); |
akashvibhute | 0:3982c0e9eda1 | 16 | |
pietor | 4:7ebc3b421306 | 17 | Ontvanger receive; |
akashvibhute | 0:3982c0e9eda1 | 18 | |
pietor | 6:6a82110ff393 | 19 | Timer t; |
pietor | 6:6a82110ff393 | 20 | |
pietor | 6:6a82110ff393 | 21 | void acitvateLed() |
pietor | 6:6a82110ff393 | 22 | { |
pietor | 6:6a82110ff393 | 23 | t.reset(); |
pietor | 6:6a82110ff393 | 24 | } |
pietor | 6:6a82110ff393 | 25 | |
akashvibhute | 2:608cf8c5c55e | 26 | int main() |
akashvibhute | 0:3982c0e9eda1 | 27 | { |
pietor | 4:7ebc3b421306 | 28 | pc.baud(9600); |
pietor | 4:7ebc3b421306 | 29 | pc.printf("Ontvangger: \r\n"); |
pietor | 6:6a82110ff393 | 30 | t.start(); |
pietor | 4:7ebc3b421306 | 31 | while(1) { |
pietor | 4:7ebc3b421306 | 32 | receive.update(); |
pietor | 4:7ebc3b421306 | 33 | while (receive.available()) { |
pietor | 4:7ebc3b421306 | 34 | payload_t payload; |
pietor | 4:7ebc3b421306 | 35 | payload = receive.read(); |
pietor | 6:6a82110ff393 | 36 | pc.printf("%d\r\n",payload.milligram); |
pietor | 6:6a82110ff393 | 37 | if (payload.reedsensor) |
pietor | 6:6a82110ff393 | 38 | acitvateLed(); |
akashvibhute | 0:3982c0e9eda1 | 39 | } |
pietor | 6:6a82110ff393 | 40 | if (t.read() <= 1) |
pietor | 6:6a82110ff393 | 41 | myled1 = myled2 = myled3 = myled4 = 1; |
pietor | 6:6a82110ff393 | 42 | else |
pietor | 6:6a82110ff393 | 43 | myled1 = myled2 = myled3 = myled4 = 0; |
akashvibhute | 0:3982c0e9eda1 | 44 | } |
akashvibhute | 0:3982c0e9eda1 | 45 | } |