Arduino Uno and RF 315MHz VirtualWire.h error

403 views
Skip to first unread message

Gleniseeee

unread,
May 28, 2014, 11:45:51 PM5/28/14
to virtu...@googlegroups.com
Hi everyone, i am encountering a problem of using the RF 315MHz wireless module for the arduino Uno.
I am running a small project to control servo motor by using joystick through RF 315MHz wireless. 
In my coding, i am using VirtualWire.h library, but the wireless coding part did not work at all.
I am printing the joystick position at the serial monitor but no data shown whenever the wireless command exist. I have to uncommand the wireless part (the 3 lines shown below), only then the joystick data will be appear at the serial monitor. 
Whats wrong with my coding? ><
Previously i try to ON/OFF 5 leds with the joystick, no prob at all. Works fine. I mean to turn ON or OFF leds to indicate the quadrant or position of the joystick. 

//  vw_set_ptt_inverted(true);
//  vw_set_tx_pin(12);
//  vw_setup(2000);


my whole coding is below; the transmitter part only;
// tx joystick
#include <VirtualWire.h>
const int poseX = 1;    // L/R
const int poseY = 0;    // U/D
const int led1 = 7;
int servoVal1;
int servoVal2;
int servoValx;
int servoValy;

void setup() {
  Serial.begin(9600);
  Serial.println("Joystick Joystick Joystick Joystick Joystick"); //
  
  pinMode(led1,OUTPUT);
  digitalWrite(led1,HIGH);
  delay(1000);
  digitalWrite(led1,LOW);
  delay(1000);
  
  vw_set_ptt_inverted(true);
  vw_set_tx_pin(12);
  vw_setup(2000);
}

void loop() {
  outputJoystick();
  servoVal1 = analogRead(poseX); 
  servoValx = map(servoVal1, 0, 1023, 170, 20);
  servoVal2 = analogRead(poseY); 
  servoValy = map(servoVal2, 0, 1023, 170, 20);
  Serial.println (" ");
  delay(250);
}

void outputJoystick() {
  Serial.print (" Pose X: ");
  Serial.println (servoValx, DEC);
  Serial.print (" Pose Y: ");
  Serial.println (servoValy, DEC);
}
///////

can anyone help me out? appreciated,thanks. :D

Mike McCauley

unread,
May 29, 2014, 1:05:30 AM5/29/14
to virtu...@googlegroups.com
Hello,


Hmmm, when I compile run the code you sent below (with those 3 lines enabled)
on an Uno here, it runs fine and prints

Pose X: 133
Pose Y: 133

Pose X: 133
Pose Y: 133
.....

Tested with Arduino 1.0.5 on Linux.

Cheers.
--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com
Phone +61 7 5598-7474 Fax +61 7 5598-7070

Dolwin Ching Ching Kho

unread,
May 29, 2014, 3:22:35 AM5/29/14
to virtu...@googlegroups.com
Really Mike??? 
That a sad for me then..haha
So can figure out what mine problem if you can run it fine while mine failed? My Uno problem??? :(


--
You received this message because you are subscribed to a topic in the Google Groups "virtualwire" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/virtualwire/UXgPyVswnj4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to virtualwire...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike McCauley

unread,
May 29, 2014, 3:24:46 AM5/29/14
to virtu...@googlegroups.com

On Thursday, May 29, 2014 03:22:34 PM Dolwin Ching Ching Kho wrote:
> Really Mike???
> That a sad for me then..haha
> So can figure out what mine problem if you can run it fine while mine
> failed? My Uno problem??? :(

Hard to say.
What version of Arduino IDE are you using?
On what platfom?

Cheers.
> > mi...@airspayce.com<javascript:;> Airspayce Pty Ltd 9 Bulbul Place
> > Currumbin Waters QLD 4223 Australia http://www.airspayce.com
> > Phone +61 7 5598-7474 Fax +61 7 5598-7070
> >
> > --
> > You received this message because you are subscribed to a topic in the
> > Google Groups "virtualwire" group.
> > To unsubscribe from this topic, visit
> > https://groups.google.com/d/topic/virtualwire/UXgPyVswnj4/unsubscribe.
> > To unsubscribe from this group and all its topics, send an email to
> > virtualwire...@googlegroups.com <javascript:;>.
> > For more options, visit https://groups.google.com/d/optout.

Dolwin Ching Ching Kho

unread,
May 29, 2014, 3:33:22 AM5/29/14
to virtu...@googlegroups.com
I am using version 1.0.5 as well but on Windows. Previously it works fine, but after play with it several times, no data​ printed on serial monitor. Cry. Haha

Regards :)

Mike McCauley

unread,
May 29, 2014, 3:38:42 AM5/29/14
to virtu...@googlegroups.com
Have you tried turning it off and on?

Dolwin Ching Ching Kho

unread,
May 29, 2014, 3:57:41 AM5/29/14
to virtu...@googlegroups.com
Yes i did, compile arduino with another code and compile again with this code etc etc etc..


--
You received this message because you are subscribed to a topic in the Google Groups "virtualwire" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/virtualwire/UXgPyVswnj4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to virtualwire...@googlegroups.com.

Nguyễn Lương Dân

unread,
Nov 14, 2014, 10:22:01 AM11/14/14
to virtu...@googlegroups.com
hi 
I checked your code compiles and runs on https://codebender.cc/?referrer=luongdan.hn.vn very good.
board should use authoring system and compile Arduino code online - they support the library lot
good luck

Vào 10:45:51 UTC+7 Thứ năm, ngày 29 tháng năm năm 2014, Gleniseeee đã viết:
test.png

Dolwin J Kho

unread,
Nov 16, 2014, 1:44:48 AM11/16/14
to virtu...@googlegroups.com
Hi Sir, thanks for this useful suggestion! :D

Thanks.
Regards,
Dolwin C.C. Kho :)

--
Reply all
Reply to author
Forward
0 new messages