Pages: 1 2 3 [4] 5   Go Down
Author Topic: VirtualWire  (Read 2163 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 1
Posts: 334
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Then how can I implement my that idea ?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46029
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Then how can I implement my that idea ?
Seeing as how you are the only one that has a clue what your idea is, I think the answer is "by yourself".
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you mean
Code:
count = vw_wait_rx_max(2000);// Non-blocking
  if (count)
  {
?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a really great thread. However, Wouldnt it be easier for all of us newbs if someone would just take the time to make a document or tutorial of this information (in plain terms)? This seems to be a hot topic. Not only here but also in other forums as well. I have learned a great deal just reading the questions and answers on this thread and like a good movie, I don't want it to end...LOL
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23688
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe a real world example would be appropriate. I can post my remote control code. It reads a keypad press and sends out 1 character.
On the receive side, it acts on the 1 character received.

Will be later tonight. The code is from the Virtualwire example, with the message sent being a 1 byte array
byte msg[1];
with the byte coming from the keypad.h library.

http://www.open.com.au/mikem/arduino/VirtualWire.pdf

Hmm, looks like the document has been updated to remove the examples!
They look to be online only now
http://www.open.com.au/mikem/arduino/VirtualWire/examples.html


Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This seems to be a hot topic.
I tend to disagree.
This is the first thread on the topic that I can remember in recent times.
I haven't used the library for at least two years.

Quote
Wouldnt it be easier for all of us newbs if someone would just take the time to make a document or tutorial of this information (in plain terms)?
Please, feel free to kick it off.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I may. However, I am still trying to understand it myself...LOL For now I will just have to keep bugging everyone here. You guys have great responses and are very responsive so thats not a bad thing.. at least not for me...
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 437
Posts: 23688
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's my loop code for sendinng out keypad presses:
Code:
void loop()
{

    // go read the keypad
  char key = keypad.getKey();                 // reading the keypad
  if(key)                                     // same as if(key != NO_KEY)- did something change?
  {
    msg[0]=key;                               // load the array with the key character
    // msg[1]=NULL;                           // Rx side seems to work without this

    digitalWrite(ledPin, true);               // Flash a light to show transmitting

    vw_send((uint8_t *)msg, strlen(msg));     // send the character out

//    Serial.println(key);                // for debugging only

    vw_wait_tx();                             // Wait until the whole message is gone

    delay (50);                               // need some delay or seem to miss key presses

    digitalWrite(ledPin, false);              // turn off the flash of LED

  }                                           // end of if(key) & transmitting a character

// do other stuff...

}                                             // end of void loop
and on the receive side
Code:
void loop(){
// look for wireless input or for unsolicited message from remote transmitter

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // Non-blocking
{
  int i;
  digitalWrite(ledPin, LOW); // Turn on LED to show working a message
   
    switch ( buf[0] )
    {    // switch on the first byte in the array for now
    // caes '0':, case'1':,  2,3,4,5,6,7,8,9,A,B,C, thru case 'D':, case '*':, and case '#': sections follow for my 16 button keypad
    }
  }
}
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://genericnerd.blogspot.com/2012/07/arduino-sending-integers-over-rf-with.html
I found this useful for understanding VW a little better. Just make sure that you match the vw_setup(2000) on the transmitter sketch and the receiver sketch if you download the code from that site because they are mismatched and will not work that way.
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 334
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void loop()
{
  uint8_t count;
if(count==true)
It doesn't make sense to test an automatic variable like this.
If you want "count" to retain its value, make it "static".

Code:
if (true)
Will always be true.
Code:
]if(false)
Will always be false.
Awh, editted your code. By the way, I do not understand the bolded part.

Thanks
« Last Edit: January 26, 2013, 05:31:12 am by Vincent19 » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
By the way, I do not understand the bolded part.
If you sort out the tags, I'll be able to see what you mean by the bolded part
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Sr. Member
****
Karma: 1
Posts: 334
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
By the way, I do not understand the bolded part.
If you sort out the tags, I'll be able to see what you mean by the bolded part
Modified !
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The constant "true" will always be true, so if you say
Code:
if(true)
, whatever follows the experession will always be executed.
If you say
Code:
if (false)
, then whatever follows will never be executed.
That's fundamental.
« Last Edit: January 26, 2013, 07:02:59 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Sr. Member
****
Karma: 1
Posts: 334
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, so it will be a different story if I assigned a variable to be 'true' or ;false' ?

Correct ?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46029
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Oh, so it will be a different story if I assigned a variable to be 'true' or ;false' ?

Correct ?
The action, based on whether the variable contains true or false, will be the same. Which action is performed will be different IF you assign the value correctly and IF you write the test correctly.
Logged

Pages: 1 2 3 [4] 5   Go Up
Jump to: