I am attempting to send a simple 2 integer transmission from one unit to another; The receiver should pick up the signal, process the 2 integers and activate a pin(7) with HIGH(1) or LOW(0) depending on the second integer.
The problem is that VirtualWire gets the data to the receiver perfectly, but i cannot "use" the information. When i Serial.println(buf*) the PROPER stuff gets printed, but when i attempt to call the buffer directly via the array index, i get 55 for the integer 7; 48 for the integer 0; and 49 for the integer 1;*
```
*// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
// 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;
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
//Serial.print("Got: ");
int pin = 0, mode = 0;
for (i = 0; i < buflen; i++)
{
Serial.println(buf[i]);
if (i == 0)
pin = (int)buf[i];
if (i == 1)
mode = buf[i];
//Serial.print(buf[i]);
//int pin = int(buf[0]), mode = buf[2];
//if (i == 2 && buf[2] == 1)
}
//Debugging
Serial.println("Pin:");
Serial.println(pin);
Serial.println("");
Serial.println("Mode:");
Serial.println(mode);
Serial.println("");
digitalWrite(pin, mode);
//Serial.println("");
// Serial.println(buf[0]);
//Serial.println("");
digitalWrite(13, false);
}
}*
```
This first lines output CORRECTLY the information to the screen, then when i address them using the array index, its all wrong.