Last active
July 10, 2023 22:41
-
-
Save joegaffey/15bc76fa8b89fa941570b381fa884ad4 to your computer and use it in GitHub Desktop.
Basic Arduino script to convert an RC controller/receiver to a joystick.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Joystick.h> | |
#define ThrottlePin 2 | |
#define SteeringPin 3 | |
int ThrottleValue; | |
int SteeringValue; | |
Joystick_ Joystick; | |
void setup() { | |
pinMode(ThrottlePin, INPUT); | |
pinMode(SteeringPin, INPUT); | |
Joystick.begin(); | |
Joystick.setXAxisRange(1900, 1050); | |
Joystick.setYAxisRange(1050, 1900); | |
} | |
void loop() { | |
ThrottleValue = pulseIn(ThrottlePin, HIGH); | |
SteeringValue = pulseIn(SteeringPin, HIGH); | |
Joystick.setXAxis(SteeringValue); | |
Joystick.setYAxis(ThrottleValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment