Bonjour voila je souhaite faire une communication simple entre un M5Stack et une carte Arduino UNO.

J'ai fais le code emetteur :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
#include <M5Stack.h>
#include <RF24.h>
RF24 radio(3, 1);
uint8_t address[] = { 0xCC, 0xCE, 0xCC, 0xCE, 0xCC };
const byte relaisPin = 7;
 
byte payload; // ce que l'on va envoyer
 
void setup(void) {
  M5.begin();
  pinMode(relaisPin, OUTPUT);
  Serial.begin(115200);
  if (!radio.begin()) {
    Serial.println(F("radio absente!!"));
    while (true) ; // erreur
  }
  radio.setPALevel(RF24_PA_LOW);
  radio.setPayloadSize(sizeof(payload)); // on envoie un byte, donc 1 octet
  radio.openWritingPipe(address);
}
 
void loop(void) {
 
  M5.update();
 
  if (M5.BtnA.wasPressed()) {
    digitalWrite(relaisPin, HIGH);
    payload = 111;
    if (radio.write(&payload, sizeof payload)) {
      Serial.println(F("Transmission 111 OK"));
    } else {
      Serial.println(F("Erreur de Transmission"));
    }
  }
 
  if (M5.BtnB.wasPressed()) {
    digitalWrite(relaisPin, LOW);
    payload = 222;
    if (radio.write(&payload, sizeof payload)) {
      Serial.println(F("Transmission 222 OK"));
    } else {
      Serial.println(F("Erreur de Transmission"));
    }
  }
}
Mais étant débutant en arduino je n'ai aucune idée pour le code recepteur qui ira sur l'Arduino UNO