Hello guys ,i still new in this arduino area, i already do alot of research but still failed . i try to transmit a data using rf433 mhz, i already succeed by sending a msg, but not for measure a distance using ultrasonic sensor
#include "Ultrasonic.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Ultrasonic ultrasonic(12,13);
// 433 Mhz radio code start
#include <VirtualWire.h>
char cad[100];
int i=0;
// 433 Mhz radio code end
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("HC-SR4 testing..");
delay(1000);
// 433 Mhz radio code start
Serial.begin(9600);
vw_setup(2000);
Serial.print("End with \".\" each data");
// 433 Mhz radio code end
}
void loop()
{
// 433 Mhz radio code start
if( Serial.available() > 0)
{
cad[i] = Serial.read();
i++;
}
if( cad[i-1] == '.')
{
cad[i] = '\0';
i=0;
vw_send((byte *)cad, strlen(cad));
delay(400);
}
// 433 Mhz radio code end
//lcd.clear();
lcd.setCursor(0, 1);
lcd.print(ultrasonic.Ranging(CM));
lcd.print("cm ");
delay(100);
}