Рет қаралды 1,121
A short video with detailed information on connecting up a Joypad/ Joystick to the Arduino (Sketch/program below and during the video).
I am using an old helicopter controller to control a CNC conversion project.
Please hit SUBSCRIBE to follow these projects.
This project developed through a need to speed up my Electric Vehicle Conversion Project.
This video goes through the following:
Connecting a Joypad to an Arduino Mega 2560.
Uploading a Sketch (Arduino Program) to the Arduino.
Isolating the joypad controls from the original circuit.
A circuit diagram of the Joypad and its new connections.
How to connect potentiometers (variable resistor) to an Arduino.
Reduce power consumption using high-value resistors in series.
Joypad values sent to the serial monitor for testing the controls.
Using an Arduino on a Breadboard with jumper wires.
Testing the circuit at each stage to prevent damage when switched on.
Here is a Simple Joypad joystick test Sketch that I use in the video: -
-----------------------------------------Arduino Sketch Begin---------------------------------------
int topPotPin = A0;
int topPotVal = 0;
int xAxisPin = A1;
int xAxisVal = 0;
int yAxisPin = A2;
int yAxisVal = 0;
int zAxisPin = A3;
int zAxisVal = 0;
int topSwtchPin = 46;
int topSwtchVal = 0;
int redLedPin = 50;
int yellowLedPin = 48;
void setup() {
pinMode(topSwtchPin, INPUT);
pinMode(topSwtchPin, INPUT_PULLUP);
pinMode(redLedPin, OUTPUT);
pinMode(yellowLedPin, OUTPUT);
Serial.begin(115200);
while (!Serial) ;
}
void loop(){
topPotVal = analogRead(topPotPin);
xAxisVal = analogRead(xAxisPin);
yAxisVal = analogRead(yAxisPin);
zAxisVal = analogRead(zAxisPin);
topSwtchVal = digitalRead(topSwtchPin);
Serial.print("X-Val = ");
Serial.print(xAxisVal);
Serial.print(" Y-Val = ");
Serial.print(yAxisVal);
Serial.print(" Z-Val = ");
Serial.print(zAxisVal);
Serial.print(" Top Val = ");
Serial.println(topPotVal);
if (topSwtchVal == 0){
digitalWrite(yellowLedPin, HIGH);
digitalWrite(redLedPin, LOW);
delay(500);
digitalWrite(redLedPin, HIGH);
delay(500);
digitalWrite(yellowLedPin, LOW);
digitalWrite(redLedPin, LOW);
delay(500);
digitalWrite(yellowLedPin, HIGH);
digitalWrite(redLedPin, HIGH);
delay(500);
}
}
----------------------------------------Arduino Sketch End-----------------------------------------
Music: www.bensound.com
Music :
Sunrise by Vexento / vexento
/ vexento
Tevo by Vexento / vexento
/ vexento
/ vexento
Music promoted by Audio Library • Tevo - Vexento (No Cop...
#WelcomeToMyGarage
#dev255