Guest User

Untitled

a guest
Mar 11th, 2015
709
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. Hi, this is a good intractable but there is a way easier way to use these modules. Instead of using Virtual Wire library, all you have to do is plug the data pin from the receiver module into the rx (0) pin on your arduino, and plug the data pin from your transceiver module into the tx (1) pin on your other arduino. There is no external library needed for this. Here is the code for the receiver:
  2.  
  3. //receiving rx code
  4.  
  5. int incomingByte = 0;
  6.  
  7. void setup(){
  8. Serial.begin(2400);
  9. }
  10.  
  11. void loop(){
  12. if (Serial.available() > 0) {
  13. incomingByte = Serial.read();
  14. Serial.println(incomingByte, DEC);
  15. }
  16. incomingByte = 0;
  17. }
  18.  
  19. Note****When uploading code to your arduino, you need to disconnect the wire from the rx pin or it won't upload.
  20.  
  21. Here is the code for the transceiver:
  22.  
  23. //sending tx code
  24.  
  25. byte counter;
  26.  
  27. void setup(){
  28. Serial.begin(2400);
  29. counter = 5;
  30. }
  31.  
  32. void loop(){
  33. Serial.write(counter);
  34. delay(10);
  35. }
  36.  
  37. Note****You need to disconnect the wire from the tx pin and reconnect it later when uploading your code to the arduino.
Advertisement
Add Comment
Please, Sign In to add comment