I want to use the 433Mhz RX-TX Kit for a single Arduino nano and I wrote the following code
I want to have two outputs for the LED one for the broadcast one for the reception.
So when the transmission lights up a led and at the reception to light the second flashing LED
Of course does not work, want help.
#include <VirtualWire.h>
char *msg = "123456789123456789";
int i;
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
void setup() {
Serial.begin(9600);
pinMode(12,OUTPUT);
pinMode(8,OUTPUT);
pinMode(6,OUTPUT);
pinMode(4,OUTPUT);
vw_setup(2000);
vw_set_tx_pin(12); //emitator in
//vw_setup(2000);
vw_set_rx_pin(8); //receptor in
vw_rx_start();
//Serial.println("Starting up");
digitalWrite(6,HIGH); //emisie on
}
void loop() {
vw_send((uint8_t*)msg, strlen(msg));
vw_wait_tx();
delay(500);
if(vw_get_message(buf,&buflen)) {
for(i=0;i<buflen; i++) {
Serial.print((char)buf*);*
digitalWrite(6,LOW); //emisie off
digitalWrite(4,HIGH); //receptie on
delay(50);
digitalWrite(4,LOW);
delay(50);
- }*
}
}
code rxtx433mhz.txt (797 Bytes)