Page 1 of 1

Arduino Uno and RF 315MHz wireless interface

PostPosted: Thu May 22, 2014 12:42 pm
by glenise
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. I mean to turn ON or OFF leds to indicate the quadrant or position of the joystick.

CODE: SELECT_ALL_CODE
//  vw_set_ptt_inverted(true);
//  vw_set_tx_pin(12);
//  vw_setup(2000);




my whole coding is below; the transmitter part only;

CODE: SELECT_ALL_CODE
// tx joystick for servo COM18
#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);
}
////

Re: Arduino Uno and RF 315MHz wireless interface

PostPosted: Mon May 26, 2014 5:04 pm
by sich
glenise WROTE:...I have to uncommand the wireless part (the 3 lines shown below), only then the joystick data will be appear at the serial monitor.

Do you mean "I have to comment the wireless part..."?

Anyway, I don't see any problem with your code. It should display the analog readings in serial monitor no matter you comment/uncomment the 3 lines related to VirtualWire library.

Re: Arduino Uno and RF 315MHz wireless interface

PostPosted: Thu May 29, 2014 10:33 am
by glenise
hmmm..i mean i have to uncomment the 3 lines i've mentioned, then i have my data on the serial monitor.
If that 3 lines of code are in, i dont get anything printed on serial monitor.
That's why i dont know whats the problem...... :(

Re: Arduino Uno and RF 315MHz wireless interface

PostPosted: Thu May 29, 2014 2:19 pm
by kl84
Hey, I've tested ur code with my Arduino uno and it works either way. Both display the analog values in serial monitor correctly.

Re: Arduino Uno and RF 315MHz wireless interface

PostPosted: Fri May 30, 2014 10:15 am
by glenise
Hmm, can figure out what possibly could be my problem if i cant get any data printed on the serial?? The same code use, Arduino Uno board programmed on ver1.0.5 using Windows. :(

Re: Arduino Uno and RF 315MHz wireless interface

PostPosted: Fri May 30, 2014 3:43 pm
by ober
How is the wiring/interface of whole system look like?

Re: Arduino Uno and RF 315MHz wireless interface

PostPosted: Tue Jun 03, 2014 1:17 pm
by glenise
Hey, sorry for the late reply. Now my system works, but i am using the 433 MHz RF module instead of the 315 MHz. Servos work ok, but experience a serious delay...... ><
Maybe my 315 MHz module down.... :mrgreen:

Re: Arduino Uno and RF 315MHz wireless interface

PostPosted: Thu Jun 12, 2014 4:26 pm
by sjwee3
[][/img]

Re: Arduino Uno and RF 315MHz wireless interface

PostPosted: Sun Jun 15, 2014 4:35 pm
by yonghui
U can try slow down the baud rate for 315mhz to 2400bps to try. Low cost rf can operate reliably at higher baud rate



Sent from my T100TA using Tapatalk