Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include <RF24.h> 00003 00004 00005 RF24 device(PA_7, PA_6, PA_5, PB_12, PB_11); 00006 DigitalIn ms(D2); 00007 DigitalIn mybutton(USER_BUTTON); 00008 const uint64_t pipe_address = 0xE8E8F0F0E1LL; 00009 00010 void receiver(); 00011 void transmitter(char* message); 00012 00013 int main() { 00014 00015 device.begin(); 00016 00017 char message[32] = "vv"; 00018 00019 if (ms){ 00020 device.openWritingPipe(pipe_address); 00021 00022 } else{ 00023 /*slave*/ 00024 00025 device.openReadingPipe(1,pipe_address); 00026 device.startListening(); 00027 00028 } 00029 00030 00031 while (1){ 00032 00033 00034 if (ms){ 00035 /*master*/ 00036 if (mybutton == 0) { 00037 00038 transmitter(message); 00039 printf("%s => emis : %d\r\n",message,sizeof(message)); 00040 wait(0.2); 00041 00042 } 00043 00044 } else{ 00045 /*slave*/ 00046 00047 receiver(); 00048 } 00049 } 00050 00051 } 00052 00053 void transmitter(char* message){ 00054 device.write(message,sizeof(message)); 00055 } 00056 00057 void receiver(){ 00058 00059 00060 // if (device.available()){ 00061 00062 char text[32]; 00063 device.read(&text, sizeof(text)); 00064 if (text[0]!='\0') 00065 printf("%s\n\r",text); 00066 // printf("%s recu : %d\n\r",text,sizeof(text)); 00067 // } 00068 } 00069 00070
Generated on Sun Jul 17 2022 21:17:41 by
1.7.2