So I have a 2 axis Joystick module that I want to connect to a NodeMCU.
The problem is the Joystick has 2 analog outputs and the NodeMCU only has 1 analog input.
I found this tutorial here and I followed all the steps, but wrote the code in Arduino IDE and IT DIDN'T WORK...
So the question remains, is there a way to connect a 2 axis Joystick to NodeMCU?
I'm so sorry I forgot to tell what really was the problem, so the values range from like 0 to 150, and are not really working well.
I drag the Joystick in the position:
UP: X is 0 Y is 134
DOWN: X is 15 Y is 144
LEFT: X is 0 Y is 134
RIGHT: X is 14 Y is 144
Also the transistors I use are TP31C transistors, NPN type.
And I know in the picture is an Arduino Uno, but I use it for testing purposes, I already tried the same configuration on NodeMCU with almost the same result, the values were a bit different.
Poor choice, this is a power transistor and they have very low gain. The configuration is an emitter follower so we are not talking about voltage gain but current gain. It well could explain your poor results. I would use a small signal transistor instead.
I do have a voltmeter, but, I checked again and I'm not sure, but in the circuit diagram the Emitter of the Transistors are wired to the Analog Pin, while I wired the Analog Pin to the Base of my TIP31C Transistor..
Well I reconfigured the wires and still, it's not working.
Turns out I declared the analog value variables as 8bit integers...
But after rewriting the code, i get the next values:
UP: X is 12 ; Y is 510.
DOWN: X is 682 ; Y is 603.
LEFT: X is 570 ; Y is 22.
RIGHT X is 572 ; Y is 684.
Guess the right choice right now is to get different transistors, or just get an analog multiplexer.
Yes, the analog out line goes to the A0 pin in the Node.
Okay I will take out the base resistors
I don't know if I need a pull down resistor, I just followed the tutorial mentioned above. But I will try to wire a pulldown resistor, in that aspect, what would be the value? Is 1k to much?
Because I want to send data to a web server using NodeMCU. And I want a lightweight version.
I would like to use the Joystick and NodeMCU to create a sort of controller for a Android Game..
Adds 4 analog inputs.
Better quality than NodeMCU's built-in analog port
Uses only 2 NodeMCU pins
Those 2 pins can still be used for other i2c devices such as sensors, LCD/oled displays...
You do know that the circuit you are trying to make can never give you the full range of readings from your A/D? This is because a transistor in common emitter mode will always have at least 0.7V between the base and emitter, giving you a fixed offset to any variation you get from your two joystick controls.
This might have been mentioned in that tutorial, but I don’t recall it.