RF Joystick For Arduino
RF Joystick For Arduino
RF Joystick For Arduino
Table of Contents
Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Step 1: Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
RF Controlled Joystick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Step 2: Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Step 3: .................................................................................................................. 5
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
http://www.instructables.com/id/RF-Joystick-for-Arduino/
Author:CCCSuffolk Creative Computing Club
Creative Computing Club provides technology based learning opportunities for all ages and abilities to participants in Suffolk. We deliver courses on
computer programming, video game design, hardware programming, web development, electronics, robotics and more. Founded in 2012 the Creative
Computing Club has helped hundreds of people take their first steps in to the world of technology.
2 X Arduino Unos
An assortment of male to male, male to female and female to female jumper leads.
4 X LED's
4 X 200? Resitors
1 X 433mhz Transmitter
1 X 433mhz Receiver
Arduino Software
Setup
Firstly download and install the the Arduino Software as per developer instructions for your operating system, secondly download and unzip the RCSwitch Arduino
Library. Place the folder inside the Arduino/libraries folder located in your Documents folder. This will allow Arduino to access it.
Step 1: Transmitter
This sketch will send either the number 1,2,3,4 or 5 depending on the position of the joystick and it will only send
a number if it is different from the previous number it read from the joystick. It will transmit it using "Digital Pin 10" and using the command "mySwitch.send(pos, 23);".
The "23" is a number unimportant in these examples however they could be used to determine which signal is going to which receiver if there was more than one.
RF Controlled Joystick
Before this example will work you will need to work out your joysticks "dead zone", these are the horizontal and vertical values of the joystick of when it is not in use. In
the code replace the "VALUE" with 0, run the code and then selct tools from the menu in the Arduino software and select Serial Monitor, this will provide you with the two
values. Stop the program and replace the two 0's with those values.
In this example we need four "female to male" jumper leads the first goes from "GND" to "GND" the second goes from "VCC" to "5v". The third "HOZ" to "AO" and finally
"VER" to "A1". Now to connect the transmitter. Firstly use a "female to male" jumper lead to connect the "GND" to "GND" on the lefthand side of the board next to "Digital
http://www.instructables.com/id/RF-Joystick-for-Arduino/
Pin 13". Secondly using a "Female to Female" jumper lead connecting the "VCC" to the top left "5v" header pin. Finally use a "female to male" jumper lead to connect the
"ATAD/DATA" pin to "Digital Pin 10". You are now set up to send some data wirelessly.
int pos = 0;
int oldpos=100;
int val = 0;
int val2 = 0;
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
void loop() {
//Read JoyStick
val = analogRead(0);
val2 = analogRead(1);
Serial.println(val);
Serial.println(val2);
//UP 1
//DOWN 2
//RIGHT 3
//LEFT 4
//DEAD ZONE 5
pos=5; Serial.println(pos);
mySwitch.send(pos, 23);
http://www.instructables.com/id/RF-Joystick-for-Arduino/
Step 2: Receiver
By now we should have the transmitter setup and transmitting 1,2,3,4 and 5 depending on the position of the
joystick. Now on this the Receiver Arduino we are going to wait for a signal, read it and decide which light to turn on or off.
Now to connect the receiver. Firstly use a "female to male" jumper lead to connect the "GND" to "GND" on the righthand side of the board. Secondly use a "female to
male" jumper lead to connect the "DOUT" pin to "Digital Pin 2". Finally using a "Female to Female" jumper lead connecting the "VCC" to the top left "5v" header pin.
Using a "male to male" jumper lead Digital Pin 4" goes to a "220?" and then on to a "LED". Using a "male to male" jumper lead "Digital Pin 5" goes to a "220?" and then
on to a "LED". Using a "male to male" jumper lead "Digital Pin 7" goes to a "220?" and then on to a "LED". Using a "male to male" jumper lead "Digital Pin 9" goes to a
"220?" and then on to a "LED". These four "LED's" are then returned to "GND" using Using a "male to male" jumper leads.
int pos = 0;
void setup() {
Serial.begin(9600);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
mySwitch.enableReceive(0);
void loop() {
if (mySwitch.available()) {
if (value > 0) {
if (mySwitch.getReceivedValue()==1){digitalWrite(4,HIGH);}
else if (mySwitch.getReceivedValue()==2){digitalWrite(5,HIGH);}
else if (mySwitch.getReceivedValue()==3){digitalWrite(8,HIGH);}
else if (mySwitch.getReceivedValue()==4){digitalWrite(9,HIGH);}
http://www.instructables.com/id/RF-Joystick-for-Arduino/
else if (mySwitch.getReceivedValue()==5){
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
mySwitch.resetAvailable();
And there you have it you should now be able to control the LEDs via a joystick on the first Arduino.
Hope you like it, please leave comments if you can think of any improvements or you use it in any of your projects.
www.creativecomputingclub.com
Step 3:
Related Instructables
http://www.instructables.com/id/RF-Joystick-for-Arduino/
Advertisements
Comments
http://www.instructables.com/id/RF-Joystick-for-Arduino/