Hello everyone, I have an idea to do car lock-unlocker with two arduinos and rf 433mnz transmitter-receiver!
I'm new to Arduino and programming languages??, until now managed to run Arduino to the computer via the communication port, but I could not manage one arduino by the other Arduino!
I have some code on whom I work, but without success!
Transmitter
Thank you very much for the answer!
Is it possible for you to show me what to change in code, because I used one character, but still it dosen't work!!!
Like that it dosen't work. If I use the code from VirtualWire for the receiver , when is pressed "a" I have (61) and for "z"-(7A). I use this numbers in my receiver code, but still no work
Receiver:
That is an infuriating, pointless, meaningless phrase. (badly spelled too)
"work" implies some so-far undisclosed observation.
"doesn't work" also implies some so-far undisclosed observation that is in some way at odds with the first.
WE CAN'T SEE YOUR PROJECT.
Have you verified (with a simple LED blink) that your receiver is receiving any messages?
I use this RF link and now everything works correctly, I just made ??a small mistake with RX pin.
From the beginning I used the code from VirtualWire, there RX is 11pin.
In my code I use 12th pin and there was a problem!!!
Thank you for the help AWOL !!!
Welcome back
I managed to make communication between two arduinos but now I want to use the entire password, not just one character !
Now I'm here:
Transmitter
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
const int buttonPin1 = A5;
int buttonState1 = 0;
String msg;
void setup()
{
vw_set_ptt_inverted(true);
vw_set_tx_pin(12);
vw_setup(2000);
pinMode(buttonPin1, INPUT);
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
if (buttonState1 == HIGH){
String msg[3] = " put ";
vw_send((uint8_t *)msg, 3);
vw_wait_tx(); // Wait until the whole message is gone
delay(1000);
}
}
Receiver
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
vw_set_ptt_inverted(true);
vw_set_rx_pin(12);
vw_setup(2000);
vw_rx_start();
pinMode(13, OUTPUT);
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
if (buf[3] == 'p','u','t')
{
for (int i = 0; i < 10; i++) {
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}
}
}
}
It works, but no matter what is the password!!!
If instead of ( 'p', 'u', 't') I put (' ', ' ', ' ') still works!
Why is it?
Can anyone explain!
Thank you
This is creating an array of String instances, initializing only the first one. That is probably not what you want.
vw_send((uint8_t *)msg, 3);
Sending a String object, and sending the data IN a String object are not the same thing.
Do yourself a BIG favor and ditch the String class. It is clear that you do not understand its purpose or how to use it. Even the string (note the lower case s) " put " has 5 characters. Why you would want to only send the first 3 is a mystery.
vw_wait_tx(); // Wait until the whole message is gone
delay(1000);
Then wait some more...
if (buf[3] == 'p','u','t')
There are so many things wrong here. buf[3] is the 4th character in the array (that contains garbage read from the sender, since the sender is sending garbage) The 4th character is being compared to the letter p. That is either true or false. If it is true, you have:
if(true, 'u', 't')
{
}
If it is false, you have
if(false, 'u', 't')
{
}
The comma operator does something. Can YOU explain what that something is? Can you make sense of these two if statements? If you can't, how can you expect that Arduino to.
The proper way to compare the input (if it were valid) would be:
But I get the following message:
-invalid conversion from 'uint8_t*' to 'const shar*'
-error: initializing argument 1 of 'int strcmp(const char*, const shar*)'