Make an Array with multiple Sensor value

Hi guys,
How can i make an Array that can store Integer with multiple Sensor value
I don't have much experience in C Programming :frowning: :frowning: :frowning:

Actually i want to send multiple sensor value through 433Mhz Tx & Rx And you know they are all mixing up in Rx Side :frowning:

Here is the code for Transmission

#include <VirtualWire.h> //Library for Transmitting data

const int xPin = A1;
const int yPin = A2;
const int zPin = A3;

#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED

int minVal = 265;
int maxVal = 402;

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance

double x;
double y;
double z;

int distanceData;
int xData;
int yData;
int zData;

char distanceCharMsg[4];
char xCharMsg[4];
char yCharMsg[4];
char zCharMsg[4];

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
   vw_setup(2000); //Bits per sec

}

void loop() {
/* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */ 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 
 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;
 
 // End of ultrasonic sensor
 //Start of Accelerometer
 
   int xRead = analogRead(xPin);
  int yRead = analogRead(yPin);
  int zRead = analogRead(zPin);

  //convert read values to degrees -90 to 90 - Needed for atan2
  int xAng = map(xRead, minVal, maxVal, -90, 90);
  int yAng = map(yRead, minVal, maxVal, -90, 90);
  int zAng = map(zRead, minVal, maxVal, -90, 90);

  //Caculate 360deg values like so: atan2(-yAng, -zAng)
  //atan2 outputs the value of -? to ? (radians)
  //We are then converting the radians to degrees
  x = RAD_TO_DEG * (atan2(-yAng, -zAng) + PI);
  y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI);
  z = RAD_TO_DEG * (atan2(-yAng, -xAng) + PI);
 
 
 Serial.print("distance");
 Serial.println(distance);
 Serial.print("x");
 Serial.println(x);
 Serial.print("y");
 Serial.println(y);
 
 
   itoa(distance,distanceCharMsg,10);
   itoa(x,xCharMsg,10);
   itoa(y,yCharMsg,10);

             vw_send((uint8_t *) distanceCharMsg,strlen(distanceCharMsg));
             vw_send((uint8_t *) xCharMsg,strlen(xCharMsg));
             vw_send((uint8_t *) yCharMsg,strlen(yCharMsg));

               vw_wait_tx();



 delay (50);
}

and Here is the code for Receiving

#include<VirtualWire.h>

int distanceData;
int xData;
int yData;
int zData;

char distanceCharMsg[4];
char xCharMsg[4];
char yCharMsg[4];



void setup()
{
    delay(1000);
    Serial.begin(9600);	// Debugging only

    // Initialise the IO and ISR



    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec

    vw_rx_start();       // Start the receiver PLL running

}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;
	// Message with a good checksum received, dump it.
	
	for (i = 0; i < buflen; i++)
	{
	    distanceCharMsg[i] = char(buf[i]);
	    Serial.print(' ');
	}
	distanceCharMsg[buflen] = '\0' ;
	xCharMsg[buflen] = '\0' ;
	yCharMsg[buflen] = '\0' ;


distanceData = atoi(distanceCharMsg);
xData = atoi(xCharMsg);
yData = atoi(yCharMsg);


Serial.print("distance");
Serial.println(distanceData);
Serial.print("x");
Serial.println(xData);
Serial.print("y");
Serial.println(yData);
    }
    delay (100);
}

Please help

You've already declared arrays - you just need to declare some different names and change the datatype.

As i said you bro, I don't have much experience =( in programming and stuffs ,Can you do it for me please

"bro"?

No, I don't think I want to do your homework, thanks all the same.

And you know they are all mixing up in Rx Side

I didn't know that, but you could fix that by giving them unique labels.

That's fine Okay!!
Else give me the hints to do that.?

Why do you need to put the values (what values exactly ?) into an array of ints ? Do you think that will help with your problem with receiving the data ?

Look bro I want to send the Data of Ultrasonic sensor and Accelerometer with 433mhz from one UNO to second UNO, If i use the above given code for transmitting and receiving then Only one value is comming in the receiving side and it is spreading in all three, How so i want to pack those values of Ultrasonic sensor and Accelerometer in a Array and send through it.!!

Why not just make up a single message for transmission using sprintf, and pick it apart using sscanf?

Look bro

I'm out of this thread.

UKHeliBob:

Look bro

I'm out of this thread.

:smiley: +1

WHY YOU DO THIS :frowning: :frowning: :frowning:

Why do we do what?
Answer your question (reply #7) then bail-out?

ok