Hello!
I am trying to measure the distance of an object using HC-204 and then transmit it over 433Mhz, transmitter receiver using Virtual wire library.
Just sending a string of "hello" works, also the distance can be obtained individually, however combining the code gives an error:
Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"
sketch_jul28ainte.ino: In function 'void loop()':
sketch_jul28ainte:39: error: invalid conversion from 'char' to 'char*' [-fpermissive]
sketch_jul28ainte:15: error: initializing argument 1 of 'void send(char*)' [-fpermissive]
invalid conversion from 'char' to 'char*' [-fpermissive]
I have typed in the code here:
#include <VirtualWire.h>
#define trigPin 13
#define echoPin 12
#define led 11
#define led2 10
void setup()
{
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
Serial.begin (9600); //this for hc-204
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop()
{ //for getting the distance
long duration, distance;
char message;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
message=distance;
send(message); // for sending the distance
delay(1000);
}
void send (char *message) //function to send message
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}
How do I get the program to work?