RF24Network Send example program.
Dependencies: xtoff RF24Network mbed
Fork of RF24Network_Send by
main.cpp@5:e6067799a414, 2018-02-12 (annotated)
- Committer:
- pietor
- Date:
- Mon Feb 12 17:16:26 2018 +0000
- Revision:
- 5:e6067799a414
- Parent:
- 4:bc1126d78e55
- Child:
- 6:03ba3e18ced2
Verzender;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pietor | 5:e6067799a414 | 1 | #include "Verzender.h" |
akashvibhute | 0:3982c0e9eda1 | 2 | Serial pc(USBTX, USBRX); |
akashvibhute | 0:3982c0e9eda1 | 3 | |
pietor | 4:bc1126d78e55 | 4 | DigitalIn pb(p25); |
pietor | 5:e6067799a414 | 5 | Verzender sent; |
akashvibhute | 0:3982c0e9eda1 | 6 | |
akashvibhute | 2:926b93a68399 | 7 | int main() |
akashvibhute | 0:3982c0e9eda1 | 8 | { |
pietor | 5:e6067799a414 | 9 | |
pietor | 4:bc1126d78e55 | 10 | pc.baud(9600); |
akashvibhute | 0:3982c0e9eda1 | 11 | wait_ms(1000); |
pietor | 5:e6067799a414 | 12 | pc.printf("mBed RF24Network node: Tx\n\r"); |
pietor | 5:e6067799a414 | 13 | pb.mode(PullUp); |
akashvibhute | 2:926b93a68399 | 14 | |
pietor | 5:e6067799a414 | 15 | while(1) { |
pietor | 5:e6067799a414 | 16 | sent.update(); |
pietor | 5:e6067799a414 | 17 | if (!pb) { |
pietor | 5:e6067799a414 | 18 | pc.printf("Sending..."); |
pietor | 5:e6067799a414 | 19 | payload_t payload; |
pietor | 5:e6067799a414 | 20 | payload.reedsensor = !pb; |
pietor | 5:e6067799a414 | 21 | payload.milligram = 521000; |
akashvibhute | 1:5be48a9550c3 | 22 | |
pietor | 5:e6067799a414 | 23 | bool ok = sent.write(payload); |
akashvibhute | 1:5be48a9550c3 | 24 | if (ok) |
pietor | 4:bc1126d78e55 | 25 | pc.printf("ok.\n\r"); |
akashvibhute | 1:5be48a9550c3 | 26 | else |
pietor | 4:bc1126d78e55 | 27 | pc.printf("failed.\n\r"); |
akashvibhute | 2:926b93a68399 | 28 | } |
akashvibhute | 0:3982c0e9eda1 | 29 | } |
akashvibhute | 0:3982c0e9eda1 | 30 | } |