Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #45 on: January 22, 2013, 07:28:30 am » |
Then how can I implement my that idea ?
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 336
Posts: 36479
Seattle, WA USA
|
 |
« Reply #46 on: January 22, 2013, 08:19:15 am » |
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
Online
Brattain Member
Karma: 144
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #47 on: January 22, 2013, 09:20:36 am » |
Did you mean 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.
|
|
|
|
USA
Offline
Jr. Member
Karma: 0
Posts: 66
|
 |
« Reply #48 on: January 22, 2013, 01:56:38 pm » |
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
Offline
Brattain Member
Karma: 270
Posts: 17059
Available for Design & Build services
|
 |
« Reply #49 on: January 22, 2013, 02:36:18 pm » |
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.pdfHmm, 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
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 144
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #50 on: January 22, 2013, 02:49:43 pm » |
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. 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.
|
|
|
|
USA
Offline
Jr. Member
Karma: 0
Posts: 66
|
 |
« Reply #51 on: January 22, 2013, 02:57:33 pm » |
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
Offline
Brattain Member
Karma: 270
Posts: 17059
Available for Design & Build services
|
 |
« Reply #52 on: January 22, 2013, 09:47:54 pm » |
Here's my loop code for sendinng out keypad presses: 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 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
|
|
|
|
|
USA
Offline
Jr. Member
Karma: 0
Posts: 66
|
 |
« Reply #53 on: January 23, 2013, 08:13:37 am » |
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
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #54 on: January 25, 2013, 08:21:19 pm » |
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". if (true) Will always be true.]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
Online
Brattain Member
Karma: 144
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #55 on: January 26, 2013, 04:16:26 am » |
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.
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #56 on: January 26, 2013, 05:31:28 am » |
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
Online
Brattain Member
Karma: 144
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #57 on: January 26, 2013, 05:43:47 am » |
The constant "true" will always be true, so if you say if(true) , whatever follows the experession will always be executed. If you say 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.
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 207
|
 |
« Reply #58 on: January 26, 2013, 06:20:17 am » |
Oh, so it will be a different story if I assigned a variable to be 'true' or ;false' ?
Correct ?
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 336
Posts: 36479
Seattle, WA USA
|
 |
« Reply #59 on: January 26, 2013, 09:14:06 am » |
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
|
|
|
|
|
|