![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dd
Dependencies: xtoff2 RF24Network mbed
Fork of xtoff3 by
main.cpp
- Committer:
- gimohd
- Date:
- 2018-07-13
- Revision:
- 15:f8aad6d1db68
- Parent:
- 14:3e69c8a9c730
- Child:
- 16:691649d8a3da
File content as of revision 15:f8aad6d1db68:
/** Main.cpp Purpose: main class @author Pieter Berteloot RF24 PINOUT: ---- ----- |GND | VCC | |---- | |CE CSN | |SCK MOSI| |MISO IRQ | ---- ----- ---- ----- |GND | Vout| |---- | |p9 p8 | |p7 p5 | |p6 NC | ---- ----- */ //uncommend #define PRINT_ENABLE to see informational prints #define PRINT_ENABLE #include "mbed.h" //#include "rtos.h" #include "Ontvanger.h" Serial pc(USBTX, USBRX); Ontvanger receiver; Timer t; DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); DigitalOut myled4(LED4); State2 current_state = init_state; //Thread thread; //Mutex stdio_mutex; //Mutex nrf_mutex; void receive() { while (true) { pc.printf("");//print niet weg doen, één of andere reden werkt het niet zonder receiver.update(); if (receiver.available()) { payload_t payload; payload = receiver.read(); if(!payload.messageAvailable) { pc.printf("%f\r\n", payload.gram); } } } } void send() { //bool ok = receive.write(packet); bool ok = true; if (ok) pc.printf("Vok.\n\r"); else pc.printf("Vfailed.\n\r"); } /** char c = 'a'; void led2_thread() { while (true) { stdio_mutex.lock(); //c = pc.getc(); pc.printf("Character %c\r\n", c); stdio_mutex.unlock(); } }**/ int main() { float massa = 69; //thread.start(receive); while (true) { pc.printf(""); wait_ms(100); receiver.update(); payload_t payload; massa++; payload.gram = massa; bool ok = receiver.write(payload); if (ok) pc.printf("ok.\r\n"); else pc.printf("failed.\r\n"); } }