Hello!
I'm new to electronics. I'm building a project so a relay emulates a mouse click. I've soldered two wires off the left mouse button. I can touch the wires together and it works like a charm. The plan is to have an arduino-controlled relay complete the circuit. Almost all the relay-related posts deal with AC. I'm dealing with an USB mouse. The relay has NClosed and NOpen posts. Just to check, I hooked the mouse to NC and it clicked (and held) like I expected.
You forgot to set up the I/O pin as an output pin, all I/O pins default to be input pins when reset or powered on. Add the following line in your setup function:
pinMode(mousePin, OUTPUT); // sets the digital pin as output
Even on I/O pins that you might be going to use as input pins, it's a good idea to set them as input pins in your setup function for better understanding of the code for yourself and others in the future.
Read all about pinMode function:
Lefty
PS: Good form posting both your code and a picture of the wiring when asking for help or advice. Saves lots of time for all involved and a great example for other newcomers to emulate.