Extreme Communication Between Two Arduinos

I have project where i want to create an accelerometer using two arduinos and an MPU6050 accelerometer/gyroscope to find the friction the friction coefficient between my rc car and the road and ultimately see how long it would take my rc car to stop if i was traveling at some speed. ( im sure i can use a kinematic equation to find avg Acceleration ,X-axis, but i just wanted to mess around with what i got and see if it gave any fruit).

The problem is that i’m not even a week old to arduino and i don’t understand how to “fully code” and i was wondering if you guys/girls/trans/any one can help me write this “simple” code ( I know i don’t understand, to you it must be simple for me it’s almost like trying to eat a bowl of legos"

the code i wrote/stole is pretty barebone, can you awesome people take a look at it and help me finish this before Half Life 3 comes out.
please ;D

Transmitter:

#include <VirtualWire.h>
const char *message = “Merry Christmas”;
int button = 2;

void setup() {
pinMode(button,INPUT);

vw_set_ptt_inverted(true); // On a communication line means that each
// party is either transmitting or receiving ( like a walkie talkie)
vw_set_tx_pin(12); // set transmitter pin
vw_setup(4000);// speed of data transfer Kbps
}

void loop(){

if (digitalRead(button) == HIGH){
message=“X”;
vw_send((uint8_t *)message, strlen(message)); // send the message
vw_wait_tx(); // Wait until the whole message is gone
delay(2000);
}
}

Receiver:

#include <VirtualWire.h>
#include <VirtualWire_Config.h>

//This code was written using the functions of the Virtual Wire Library.
//Function list here: VirtualWire: VirtualWire.h File Reference

// Code is designed for the circuit built in this tutorial: RF 433Mhz Remote Communication Circuit - YouTube
// Written by Sanjin Dedic as a part of Robotix Arduino Tutorial Course
// http://robotix.com.au/tutorials.html

#include <VirtualWire.h>
int ledPassive = 5; //standby light
int ledActive = 7; //green LED’s
int buzzer = 8;

void setup()
{
pinMode(ledPassive,OUTPUT);
pinMode(ledActive,OUTPUT);
pinMode(buzzer,OUTPUT);
vw_set_ptt_inverted(true); // On a communication line means that each
// party is either transmitting or receiving ( like a walkie talkie)
vw_set_rx_pin(12); // set receiver pin
vw_setup(4000); // Bits per sec
vw_rx_start(); // Start Phase Locked Loop (listening to the receiver)
}
void loop()
{
digitalWrite(ledPassive,HIGH);
digitalWrite(buzzer,LOW);
digitalWrite(ledActive,LOW);
uint8_t buf[VW_MAX_MESSAGE_LEN]; // 80 bytes is messgage length
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) { // if message received
if(buf[0]==‘X’){ // and if the first letter in message array is X
digitalWrite(ledPassive,LOW);
for(int i=0;i<10;i++){ // loop alternates between LED and buzzer
digitalWrite(buzzer,LOW);
digitalWrite(ledActive,HIGH);
delay(200);
digitalWrite(buzzer,HIGH);
digitalWrite(ledActive,LOW);
delay(200);
}
}
else if(buf[0]!=‘X’){
digitalWrite(ledPassive,HIGH);
}

}
}

transmitter.ino (944 Bytes)

reciever.ino (1.66 KB)

if you can help me out, i would really appreciate it!

If we are to help you, perhaps you should state your Problem.

Sounds like you just need to build up a message from your gyro data. You didn't include anything about a gyro in your code so all I can give you is the general advise to use sprintf. If you google that you'll find tons of info on how.

The information on building a data packet to send and parsing upon reception in the serial input basics thread may be of interest.

First learn how to use VirtualWire, not by following one of those really awful Instructables, but by getting an example from the original VirtualWire library working.