Registers being truncated with Modbus master

made this program to use ardiuno as a modbus master and when i verifry the code i get told by holding registers were truncated, how can i avoid this?

error message:

C:\Users\luke\Desktop\FINAL PROJECTY\sketch_may16a\sketch_may20b\sketch_may20b.ino:83:39: warning: large integer implicitly truncated to unsigned type [-Woverflow]

node.writeSingleRegister(0x40002,0); //Writes 0 to 0x40002 holding register

program:

#include <ModbusMaster.h>              //Library for using ModbusMaster

#define MAX485_DE      3
#define MAX485_RE_NEG  2

ModbusMaster node;                    //object node for class ModbusMaster



void preTransmission()            //Function for setting stste of Pins DE & RE of RS-485
{
  digitalWrite(MAX485_RE_NEG, 1);             
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}

void setup()
{
  
  Serial.println("Modbus Master");
  delay(3000);
  
  
  pinMode(MAX485_RE_NEG, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);
  
  pinMode(4,INPUT);
  pinMode(5,INPUT);

digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);

  Serial.begin(115200);             //Baud Rate as 115200

  node.begin(1, Serial);            //Slave ID as 1
  node.preTransmission(preTransmission);         //Callback for configuring RS-485 Transreceiver correctly
  node.postTransmission(postTransmission);
}

void loop()
{
  float value = analogRead(A0);
  
  node.writeSingleRegister(0x40000,value);        //Writes value to 0x40000 holding register
  

  Serial.println("POT Val :");
  Serial.println(value);
  int a= digitalRead(4);                           //Reads state of push button 
  int b= digitalRead(5);

  if (a == 1)
  {
    
                                           
    node.writeSingleRegister(0x40001,1); //Writes 1 to 0x40001 holding register
   
    Serial.println("S1: 1");
  }
  else
  {
    node.writeSingleRegister(0x40001,0);              //Writes 0 to 0x40001 holding register
    
    Serial.println("S1: 0");
  }
  if (b == 1)
  {
    node.writeSingleRegister(0x40002,1);              //Writes 1 to 0x40002 holding register
   
    Serial.println("S2: 1");
  }
  else
  {
    node.writeSingleRegister(0x40002,0);                //Writes 0 to 0x40002 holding register
  
    Serial.println("S2: 0");
  }
 
}

sketch_may20b.ino (2.02 KB)

More members will see your code if you post it according to the forum guidelines. Read the how to use this forum-please read sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Please post error message as text. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

on 8bit Arduino maximum int size is 0x7FFF. unsigned int size 0xFFFF.
0x40000 is larger.
the modbus addresses of holding registers are in 40000 decimal range not hexa