I am using a Teensy 3.1 as an HID Keyboard, and I am trying to read input from 6 different buttons. To save space and make my soldering easier and less time consuming, I tried to create a common ground and input voltage for all of my buttons (3v from the teensy). However, although I have an analog stick sending input and know that the code is correct, I am getting no input from the buttons.
Here is the code I am trying to use (YES, I have tried testing the input with Serial, there is no change):
int a_value = digitalRead(aPin);
if(a_value == HIGH)
Keyboard.set_key3(KEY_A);
int b_value = digitalRead(bPin);
if(b_value == HIGH)
Keyboard.set_key4(KEY_B);
int x_value = digitalRead(xPin);
if(x_value == HIGH)
Keyboard.set_key5(KEY_X);
int y_value = digitalRead(yPin);
if(y_value == HIGH)
Keyboard.set_key6(KEY_Y);
Keyboard.send_now();
// Key 1 and 2 were the Arrow Key sends from analog stick
Keyboard.set_key1(0);
Keyboard.set_key2(0);
Keyboard.set_key3(0);
Keyboard.set_key4(0);
Keyboard.set_key5(0);
Keyboard.set_key6(0);
Here is a diagram of the button setup attached (same colors connect at junctions but don't with different colors):
EDIT:: Turns out there was a voltage wired to a data line.
Now that I've rewired it and place the voltage to the correct place on the button, all inputs are set to ON. It just keeps typing abxyabxyabxy... forever. And I don't mean that they're all set to high and I have to read low, I mean that all of the buttons are stuck on HIGH.
It would help immensely if you posted all the code. By definition you don't know what is wrong because you are asking what is wrong. So why do you think you know enough to be able to pick out the bit of your code where the error is?
Let me tell you, you can't.
Thank you. After finally rewiring it seems that the inner pullup resistor was what I needed to do. I t seems to be working now.
I don't know if it was intentional, but I think you should know , they are not called "inner pullups".
They are called INTERNAL pullups. That may mean absolutely nothing to you but I can tell for a fact that if you repeat that in the presence of any experienced engineer he is going to look at you funny. . Maybe it's a language thing. I don't know but let's just say, if you don't want to sound "inexperienced", say "Internal PUllups" .
Nothing personal you understand. Just consider it an "FYI" . It would be like a chemist saying "beaker " instead of "testtube". Nobody outside the industry would have a clue. But to the people who know it would "raise eyebrows" shall we say, if you know what I mean. I mean , you wouldn't tell your mother , for example. It is what it is. You dropped in. I'm here, just though I'd let you know , just in case you cared. (not that you should) For all I know it was a typo and you already knew. Consider it a "freebie".
Yes I know. I was fumbling for the right word, but I decided to go ahead and post where it would make sense at least. About 20 minutes later I realized the right word was "internal," and needless to say I gave myself a good facepalm!