Hi,
First post here, any pointers would be appreciated.
I am trying to figure out how to use an Arduino as a keyboard HID with three pin LED Arcade buttons as the inputs.
The button are from with the Hikig Zero Delay LED kit(see Pics) and the buttons are the 3 pin versions not 4, if it was 4 I would be golden but this is not the case.
So without going into too much detail about all the rabbit holes I have gone down I am at a point where I am trying to reproduce the the functionality of the button using a breadboard only. While doing this I have stumbled upon what I assume is a very basic issue but I don't have a fundamental understanding for why.
This is a simple button circuit with an LED attached, when the button is pressed I want the LED to light up as well as change the state on Pin 9. I am using the internal pullup on pin 9 and will print HIGH or LOW to COM4 based on the button being pressed or not.
So my questions is this: Why does this work when the LED is not in the circuit, the serial monitor shows the state changes, all is good. When the LED is attached the voltage doesn't drop to zero and the pin stays HIGH, the LED does light up.
Measuring from PWR to Pin 9:
Button not pressed = 0V (no LED)
Button not pressed = 0V (with LED)
Button pressed = +5V (no LED)
Button pressed = +2.38V (with LED)???
Measuring from PWR to GND
Button not pressed = +5V (no LED)
Button not pressed = +5V (with LED)
Button pressed = +5V (no LED)
Button pressed = +5V (with LED)
Measuring from Pin 9 to GND
Button not pressed = +5V (no LED)
Button not pressed = +5V (with LED)
Button pressed = 0V (no LED)
Button pressed = +2.73V dropped (with LED)???
While it will be great if someone can tell me the straight forward answer if anyone has a recommended "Intro to Electronics" book that would have allowed me to answer this myself that would be great too.
Here is my code:
#define PIN_D 9 // Pin for d
void setup(){
pinMode(PIN_D, INPUT_PULLUP);
Serial.begin(9600); // Setup Serial communication
}
void loop(){
if (digitalRead(PIN_D) == LOW) {
Serial.println("LOW");
}else{
Serial.println("HIGH");
}
delay(100);
}