I have a project for witch I want to send code from one Arduino to another and then have the receiver to change lights.
And so to achieve this, I thought after its been received by punting it into an int ill be able to easy control the other Arduino. (Using vertical wire)
I have put my code below, if you could find out why this isn't working it will be very helpful. by the way i'm using Arduino UNOs.
//Transmitter Code (Uno)
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600);
vw_setup(2000);
vw_set_tx_pin(7);
}
void loop()
{
if(Serial.available())
{
char c = Serial.read();
vw_send((uint8_t *)int(c), 2);
vw_wait_tx();
}
}
//Reciever Code (Uno)
#include <VirtualWire.h>
void setup()
{
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
vw_setup(2000);
vw_set_rx_pin(7);
vw_rx_start();
}
void loop()
{
int(c);
uint8_t buflen = VW_MAX_MESSAGE_LEN;
uint8_t buf[buflen];
if(vw_get_message(buf, &buflen))
{
for(int i = 0;i < buflen;i++)
{
c == (buf[i]); //puts recived code into an int
Serial.print(c); //testing only
}
}
if(c = 1)
{
Serial.print("1");
}
if(c = 2)
{
Serial.print("2");
}
}