Interfacing arduino with a wheelchair joystick

Since you are working on a wheelchair, I suggest you contact atmakers.org

Did you figure out the joystick pinout? I have one and I plannning to use in a different application.

thanks

I found the gimbal wiring.

Basic it's a hall effect, 4 analog output 1024 resolution

7 - Vcc
5 - GND
6- Out1.1 - ↑ - (0- 1024)
8- Out1.2 - ↓ - (0- 1024)
3- Out2.1 - ← - (0- 1024)
1- Out2.2 - → - (0- 1024)

I have recorded data transmission between joystick and controller. I am working on communication protocol. If you need, i can share my files.

1 Like

Can you share your files with me?

How to deal with that digram with arduino ?

can you share the data that you have recorded please

Hi , have you figured out what the communication protocol is ? I tried CAN,LIN,UART,I2C,SPI,1 wire protocols. I still couldn't decode it.

I read somewhere that the joystick uses Hall sensors. You might start with a regular joystick that uses pots then convert to a joystick that uses hall sensors. I imagine there are small magnets on the stick and as the magnets come closer to the hall sensors the reading increases. You can use the map function to produce an x,y reading from 0,255 and a BT2 30 amp motor driver for the 2 motors.

here is the map example:]
if (xAxis > 550){
// Convert the increasing X-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed
motorSpeedA = map(xAxis, 550, 1023, 0, 255);
motorSpeedB = map(xAxis, 550, 1023, 0, 255);
}
Here is a really good YT tutorial on H bridges and he uses a joystick in one example. https://www.youtube.com/watch?v=ygrsIqWOh3Y

`Here is a arduino wheelchair code for record and playback that Bing AI wrote. It uses a L298N Dual H-Bridge
<code>
// Arduino joystick DC motor speed and rotation direction control for X and Y axis
#define joystickX A0
#define joystickY A1
#define pwm1 9
#define pwm2 10
#define pwm3 11
#define pwm4 12
#define recordSwitch 2
#define playbackSwitch 3

int motorX_control;
int motorY_control;
bool recording = false;
bool playing = false;

void setup() {
pinMode(pwm1, OUTPUT);
pinMode(pwm2, OUTPUT);
pinMode(pwm3, OUTPUT);
pinMode(pwm4, OUTPUT);
pinMode(recordSwitch, INPUT_PULLUP);
pinMode(playbackSwitch, INPUT_PULLUP);
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
if (!SD.begin(4)) {
Serial.println("SD card initialization failed!");
return;
}
}

void loop() {
if (digitalRead(recordSwitch) == LOW) {
recording = true;
playing = false;
Serial.println("Recording...");
}
if (digitalRead(playbackSwitch) == LOW) {
recording = false;
playing = true;
Serial.println("Playing back...");
}
if (recording) {
motorX_control = analogRead(joystickX);
motorX_control >>= 1;
motorY_control = analogRead(joystickY);
motorY_control >>= 1;
if(motorX_control > 255){
digitalWrite(pwm2, 0);
analogWrite(pwm1, (motorX_control - 256));
} else if(motorX_control < 255){
digitalWrite(pwm1, 0);
analogWrite(pwm2, (255 - motorX_control));
} else {
digitalWrite(pwm1, 0);
digitalWrite(pwm2, 0);
}
if(motorY_control > 255){
digitalWrite(pwm4, 0);
analogWrite(pwm3, (motorY_control - 256));
} else if(motorY_control < 255){
digitalWrite(pwm3, 0);
analogWrite(pwm4, (255 - motorY_control));
} else {
digitalWrite(pwm3, 0);
digitalWrite(pwm4, 0);
}
File dataFile = SD.open("data.txt", FILE_WRITE);
if (dataFile) {
dataFile.print(motorX_control);
dataFile.print(",");
dataFile.println(motorY_control);
dataFile.close();
} else {
Serial.println("error opening data.txt");
}
}
if (playing) {
File dataFile = SD.open("data.txt");
if (dataFile) {
while (dataFile.available()) {
String line = dataFile.readStringUntil('\n');
int commaIndex = line.indexOf(',');
motorX_control = line.substring(0, commaIndex).toInt();
motorY_control = line.substring(commaIndex + 1).toInt();
if(motorX_control > 255){
digitalWrite(pwm2, 0);
analogWrite(pwm1, (motorX_control - 256));
} else if(motorX_control < 255){
digitalWrite(pwm1, 0);
analogWrite(pwm2, (255 - motorX_control));
} else {
digitalWrite(pwm1, 0);
digitalWrite(pwm2, 0);
}
if(motorY_control > 255){
digitalWrite(pwm4, 0);
analogWrite(pwm3, (motorY_control - 256));
} else if(motorY_control < 255){
digitalWrite(pwm3, 0);
analogWrite(pwm4, (255 - motorY_control));
} else {
digitalWrite(pwm3, 0);
digitalWrite(pwm4, 0);
}
delay(10); // adjust this value to change the playback speed
}
dataFile.close();
} else {
Serial.println("error opening data.txt");
}
}
}

To use this code, you will need to connect an SD card module to the Arduino and modify the code to use the appropriate pins for the SD card module.
You will also need to modify the code to use the appropriate file name and format for your data.
You will also need to connect two switches to the Arduino’s digital pins 2 and 3 for recording and playback control.
Please refer to the circuit schematic diagram in the source link for more details 1.

I hope this helps!

I am attaching my files here
To open it you need Logic software from Saleae.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.