So i am a complete noob when it comes to this stuff.
In the past i have have repaired games consoles but never really ventured into programming.
My current project is a self contained photo booth, which i need to have ready to rock by the 5th december.
I have sorted the whole thing, and built it myself from scratch EXCEPT the trigger button.
I am really struggling to get a simple momentary switch to act as a usb HID and create a space " " to trigger the booth.
so ive got to work with:
Arduino Leonardo Board
A Bread Board
a capacitor 10k (i think)
a momentary switch (illuminated)
Wire
USB
SO...... I've "programmed" the board, but i cant test if it works, as when i wire the button up as per the diagram i got from this site, nothing happens.
I cant get the button to illuminate. Nor can i get the button to add the space character or even be recognized as a HID.
Im in the UK so a lot of the resources online are not available here, i've got the closest alternative.
We really can't read minds from a distance. Please post the code you are using and a wiring diagram (preferably with a photo in case your wiring doesn't match the diagram). Read the first article in this forum, that says how to post code.
I have to add, i got annoyed and took it apart, so the 5v and gnd may be in the wrong positions in this pic, as i threw them together to illustrate what ive done.
Code:
/*
Button.pde
*/
void setup() {
Serial.begin(9600);
pinMode(10, INPUT_PULLUP);
delay(4000);
}
void loop() {
if (digitalRead(10) == HIGH) {
delay(10);
} else {
Keyboard.print(" "); // we print a space
delay(1000);
}
delay(10);
}
If you have multiple wire colors, it is helpful to trace the circuit to use a different colored wire for each pin. Conventionally people use black wires for ground wires, and red wires for power, and other wires for pins. The wires themselves don't care what the color of the wrapper is, but it helps other people who might want to help you.
The top wire that goes from the ground power rail on the breadboard left row #2 is not connected to anything. Presumably, you wanted to connect it to row 5 where the button is.
Second, you have a resistor between ground and power connecting left rows 5 & 10 for a pull-down resistor. However in your code you say the mode is INPUT_PULLUP. If you are going to use INPUT_PULLUP, then you don't want the resistor, and just connect one edge of the button to ground, and the other to the pin you are reading from. One note about using INPUT_PULLUP's is the return value is reversed, so it returns LOW when the button is pressed, and HIGH when it is not pressed. If you want to keep the resistor and have it return HIGH when the button is pressed, you should use the INPUT method instead of INPUT_PULLUP.
Third, the connection from the pin is to the breadboard right #4, but the other end of the button is connected to breadboard right #6. Like the first issue, these need to be in the same row on the same side of the breadboard to make contact.
Fourth, your code uses PIN 10 for the input pin, while the pin you connected on the board is PIN 1. You want to move the wire to pin #10. Since you are using the USB connection, you do not want to use pins 0 or 1, since those are used in the USB communication.