I'm trying to add a 4-way joystick with a push in switch to my Teensy 3.6 project.
I have it wired following the tutorial here: https://www.brainy-bits.com/arduino-joystick-tutorial/
However, I'm using one of my MCP23017 pins for the switch and that is working fine.
The X axis I had connected to A21 and the Y axis I had connected to A22 but neither joystick movement showed any changes in the serial monitor of the X or Y values. They didn't change much at all.
The following code worked fine on a separate bread board with a Teensy 3.2 on it. I connected X to A0 and Y to A1.
Then I connected the joystick to my main project bread board with a Teensy 3.6 using the same code as above except I initially connected to A21 and A22 but, as stated at the top, joystick movement didn't change the X Y values very much.
I already was using Teensy 3.6 pins D14 and D15 as digital pins. I removed those wires and connected my X and Y axis to those pins as analog A0 (D14) and A1 (D15). The X axis responded fine and I could see a large swing in the X axis high and low values. The Y axis values had full swing on the high value (going up to 1023) but when I pushed the Y axis the other direction towards the low values, the low values did show up, but the serial display slowed down...showing the low Y axis values about once every 3 secs. Normally I was seeing both X axis values and the high end Y axis values about 10 lines in the serial monitor every second. But the low end Y axis value is only showing about once every 3 to 4 seconds.
So I have two issues:
1. I don't know why the Y axis low side value slow down the whole system.
2. I'd like to make use of the A21 and A22 pins but they don't seem to work, so I must be doing something wrong there. I'm looking at the top side of the 3.6 pins diagram for reference as I can't get to the pins on the bottom side.
The first attachment shows the normal high Y axis speed display.
The second attachment shows the low end of the Y axis displaying the value 4 about every three seconds in the monitor.
Thanks for any help.
I have it wired following the tutorial here: https://www.brainy-bits.com/arduino-joystick-tutorial/
However, I'm using one of my MCP23017 pins for the switch and that is working fine.
The X axis I had connected to A21 and the Y axis I had connected to A22 but neither joystick movement showed any changes in the serial monitor of the X or Y values. They didn't change much at all.
The following code worked fine on a separate bread board with a Teensy 3.2 on it. I connected X to A0 and Y to A1.
Code:
// Arduino pin numbers
const int SW_pin = 2; // digital pin connected to switch output
const int X_pin = 0; // analog pin connected to X output
const int Y_pin = 1; // analog pin connected to Y output
void setup() {
pinMode(SW_pin, INPUT);
digitalWrite(SW_pin, HIGH);
Serial.begin(115200);
}
void loop() {
Serial.print("Switch: ");
Serial.print(digitalRead(SW_pin));
Serial.print("\n");
Serial.print("X-axis: ");
Serial.print(analogRead(X_pin));
Serial.print("\n");
Serial.print("Y-axis: ");
Serial.println(analogRead(Y_pin));
Serial.print("\n\n");
delay(1000);
}
Then I connected the joystick to my main project bread board with a Teensy 3.6 using the same code as above except I initially connected to A21 and A22 but, as stated at the top, joystick movement didn't change the X Y values very much.
I already was using Teensy 3.6 pins D14 and D15 as digital pins. I removed those wires and connected my X and Y axis to those pins as analog A0 (D14) and A1 (D15). The X axis responded fine and I could see a large swing in the X axis high and low values. The Y axis values had full swing on the high value (going up to 1023) but when I pushed the Y axis the other direction towards the low values, the low values did show up, but the serial display slowed down...showing the low Y axis values about once every 3 secs. Normally I was seeing both X axis values and the high end Y axis values about 10 lines in the serial monitor every second. But the low end Y axis value is only showing about once every 3 to 4 seconds.
So I have two issues:
1. I don't know why the Y axis low side value slow down the whole system.
2. I'd like to make use of the A21 and A22 pins but they don't seem to work, so I must be doing something wrong there. I'm looking at the top side of the 3.6 pins diagram for reference as I can't get to the pins on the bottom side.
The first attachment shows the normal high Y axis speed display.
The second attachment shows the low end of the Y axis displaying the value 4 about every three seconds in the monitor.
Thanks for any help.