invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermiss

Bonjour

Je souhaite programmer une télécommande basique avec la bibliothèque virtualwire.h
Si on appuis sur un des 5 boutons cela envoie un code à un récepteur.

Voici le code :

#include <VirtualWire.h>
int LedPin = 13;
int entree_tx= 1; 
uint8_t vw_send(uint8_t* buf, uint8_t len);


void setup() {
  
 pinMode (1, OUTPUT);
 pinMode(2, INPUT); 
 pinMode(3, INPUT);  
 pinMode(4, INPUT); 
 pinMode(5, INPUT);
 pinMode(6, INPUT);
  pinMode (LedPin, OUTPUT);
   vw_set_tx_pin(entree_tx);
   vw_setup(2000);
    Serial.begin(9600);
    Serial.println ("INITIALISATION OK"); }


void loop() {

int LAMPE_PISCINE ;
int LAMPE_TERRASSE ;  
int STORE_UP ;  
int STORE_STOP ;
int STORE_DOWN ;
 int B ;

LAMPE_PISCINE = digitalRead (2) ;
LAMPE_TERRASSE = digitalRead (3) ; 
STORE_UP = digitalRead (4) ;
STORE_STOP = digitalRead (5) ;
STORE_DOWN = digitalRead (6) ;
 B = 1 ;

if (LAMPE_PISCINE == B){                              // A configurer en mode 2 : Auto-lock
  Serial.println("LAMPE_PISCINE == 1310740"); 
  vw_send(1310740,24); 
  vw_wait_tx(); 
  digitalWrite (LedPin, HIGH); 
  delay (20);
  digitalWrite (LedPin, LOW); }
  
else if (LAMPE_TERRASSE == B){                        // A configurer en mode 2 : Auto-lock
  Serial.println("LAMPE_TERRASSE == 1310741");
  vw_send(1310741,24); 
  vw_wait_tx();
  digitalWrite (LedPin, HIGH); 
  delay (20);
  digitalWrite (LedPin, LOW); }
 
else if (STORE_UP == B){                              // A configurer en mode 3 : Inter-lock
  Serial.println("STORE_UP == 1327124");
  vw_send(1327124,24); 
  vw_wait_tx();
  digitalWrite (LedPin, HIGH); 
  delay (20);
  digitalWrite (LedPin, LOW);
     if (STORE_STOP == B){                       
       Serial.println("STORE_STOP == 1327125");
       vw_send(1327125,24); 
       vw_wait_tx();
       digitalWrite (LedPin, HIGH); 
       delay (20);
       digitalWrite (LedPin, LOW); }
     else {
       delay (90000);
       Serial.println("STORE_STOP == 1327125");
       vw_send(1327125,24); 
       vw_wait_tx();
       digitalWrite (LedPin, HIGH); 
       delay (20);
       digitalWrite (LedPin, LOW); }}

else if (STORE_DOWN == B){                            // A configurer en mode 3 : Inter-lock
  Serial.println("STORE_DOWN == 1314836");
  vw_send(1314836,24); 
  vw_wait_tx();
  digitalWrite (LedPin, HIGH); 
  delay (20);
  digitalWrite (LedPin, LOW);
     if (STORE_STOP == B){                       
       Serial.println("STORE_STOP == 1327125");
       vw_send(1327125,24); 
       vw_wait_tx();
       digitalWrite (LedPin, HIGH); 
       delay (20);
       digitalWrite (LedPin, LOW); }
     else {
       delay (90000);
       Serial.println("STORE_STOP == 1327125");
       vw_send(1327125,24); 
       vw_wait_tx();
       digitalWrite (LedPin, HIGH); 
       delay (20);
       digitalWrite (LedPin, LOW); }}
 else ; }

Mais quant je le fait vérifier je tombe sur ce message d’erreur

:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino: In function 'void loop()':

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:41:21: warning: invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

   vw_send(1310740,24); 

                     ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:5:9: note: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'

 uint8_t vw_send(uint8_t* buf, uint8_t len);

         ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:49:21: warning: invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

   vw_send(1310741,24); 

                     ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:5:9: note: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'

 uint8_t vw_send(uint8_t* buf, uint8_t len);

         ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:57:21: warning: invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

   vw_send(1327124,24); 

                     ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:5:9: note: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'

 uint8_t vw_send(uint8_t* buf, uint8_t len);

         ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:64:26: warning: invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

        vw_send(1327125,24); 

                          ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:5:9: note: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'

 uint8_t vw_send(uint8_t* buf, uint8_t len);

         ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:72:26: warning: invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

        vw_send(1327125,24); 

                          ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:5:9: note: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'

 uint8_t vw_send(uint8_t* buf, uint8_t len);

         ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:80:21: warning: invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

   vw_send(1314836,24); 

                     ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:5:9: note: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'

 uint8_t vw_send(uint8_t* buf, uint8_t len);

         ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:87:26: warning: invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

        vw_send(1327125,24); 

                          ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:5:9: note: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'

 uint8_t vw_send(uint8_t* buf, uint8_t len);

         ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:95:26: warning: invalid conversion from 'long int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

        vw_send(1327125,24); 

                          ^

D:\Arduino\Programmes\Telecommande_papa_2\Telecommande_papa_2.ino:5:9: note: initializing argument 1 of 'uint8_t vw_send(uint8_t*, uint8_t)'

 uint8_t vw_send(uint8_t* buf, uint8_t len);

         ^


Le croquis utilise 4 096 octets (12%) de l'espace de stockage de programmes. Le maximum est de 32 256 octets.
Les variables globales utilisent 427 octets (20%) de mémoire dynamique, ce qui laisse 1 621 octets pour les variables locales. Le maximum est de 2 048 octets.

Si quelqu’un peux m’aider ça serai super.

Merci

This is an English forum.. vw_send takes a pointer as data and a byte with the length of the data. You are using an "int" as argument and 24 as length. This cannot work since an int is only 2 bytes.

int data = 12345;
vw_send(&data, sizeof(data));

Hello (Okay in English)

I don’t understand how to modify my code so that it works

I should declare a variable for each of my codes, but what type of variable would be better.

Sorry I start at coding and I block a lot.

Thank

I should declare a variable for each of my codes, but what type of variable would be better.

What is the receiving code? Are you looking for a character string "1310740" or an integer?

Your codes are larger than 2 byte integers. They should be typed as unsigned long which are 4 bytes.

If you are sending the multi byte integer, virtual wire wants the explicit byte cast.

int data = 12345;
//vw_send(&data, sizeof(data));
vw_send((byte*)&data, sizeof(data));