RF digitalwrite from analogueRead

Before I take a hammer to this f### thing can someone tell me how use data from a pot being received by a RF receiver to switch a relay.

I have virtualWire running sweet as and everything is doing what it should in the serial monitor. So I figured if i sent the same data to an analogue in pin and read that with an if analogueRead i could set a digitalWrite high or low. But I just can hack it.

This must be simple but i just go a block on it.

Thanks

#include <VirtualWire.h>
const int numberOfAnalogPins = 1; // how many analog integer values to receive
int data[numberOfAnalogPins]; // the data buffer
int ledPin = 13; // Solenoid connected to transitor on pin 13
// the number of bytes in the data buffer

int intAnValue=0;
const byte AnInputPin=0;

const byte LED0=10;//LED for LS bit connected here
const byte LED1=9;//LED connected here
const byte LED2=8;//LED for MS bit connected here


const int dataBytes = numberOfAnalogPins * sizeof(int);
byte msgLength = dataBytes;
void setup()
{
  Serial.begin(9600);
Serial.println("Ready");
// Initialize the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver

{
   pinMode(LED0,OUTPUT);
   pinMode(LED1,OUTPUT);
   pinMode(LED2,OUTPUT);

}

}
void loop()
{
intAnValue=analogRead(AnInputPin);
setLEDs(0,0,0);
if (intAnValue>299) setLEDs(0,0,1);
if (intAnValue>500) setLEDs(0,1,0);
if (intAnValue>700) setLEDs(1,0,0);
delay(500);//To slow down how rapidly readings are taken.

}

void setLEDs(byte bL2, byte bL1, byte bL0)
{
   if (bL0==0) digitalWrite(LED0,LOW);
               else  digitalWrite(LED0,HIGH);
   if (bL1==0) digitalWrite(LED1,LOW);
               else  digitalWrite(LED1,HIGH);
   if (bL2==0) digitalWrite(LED2,LOW);
               else  digitalWrite(LED2,HIGH);


if (vw_get_message((byte*)data, &msgLength)) // Non-blocking
{
Serial.println("Got: ");
if(msgLength == dataBytes)
{
for (int i = 0; i < numberOfAnalogPins; i++)
{
/*int val = digitalRead(11); // read input value
digitalRead(11);
if (val < 10) // check if the switch is pressed
{
digitalWrite(ledPin, HIGH); // turn LED on if switch is pressed
}
else
{
digitalWrite(ledPin, LOW); // turn LED off
*/
digitalWrite(ledPin, HIGH); // turn LED on if switch is pressed
Serial.print("pin ");
Serial.print(i);
Serial.print("=");
Serial.println(data[i]);
digitalWrite(ledPin, LOW); // turn LED on if switch is pressed
delay(1000); // waits for a second


}
}
else
{
Serial.print("unexpected msg length of ");
Serial.println(msgLength);
}
Serial.println();
}
}

First, tone down the frustration. We can help you.

Second, you did not use the # button when posting your code, so the forum software mangled some of it.

Modify your post. Select the code, and delete it. Then, press the # button, and re-paste your code. Save the changes.

So I figured if i sent the same data to an analogue in pin

I'm not sure why you thought this. You are sending ASCII data using VirtualWire. You can't send ASCII data to an analog pin. Analog pins read voltage.

You could convert the ASCII data to ints, and use them directly to control PWM pins or toggle relays.

When the code posted here runs, what shows up in the Serial Monitor? Post some sample output.

Thanks for the chill pill Pauls. Just been a long day and needed to step back. Actually i had gone to bed but you got me up again. Better hit the sack tho or I will be useless tomorrow.

Thanks for any help you can offer.