Arduino: Common Ground Issue? Powering Buzzer, LEDs via transistor as a switch
Your NPN power transistor seems to be connected up wrongly.

I'd expect something like this ...







simulate this circuit &ndash; Schematic created using CircuitLab

where 


R1 limits base current and protects P1.  \$R_1 = 5V - V_{BE(sat)} / I_B(20mA?)\$
R2 limits LED current.  \$R_2 = (18V - V_{LED} )/ I_{LED}\$
Q1's collector is connected to the LED's cathode.


Perhaps your LED is actually an 18V LED module that has current-limiting built in?

Note: I believe piezo buzzers don't draw much current, you probably don't need a TIP31 to drive it. Check the specs and choose a more suitable transistor. To be connected as shown, the piezo buzzer should be rated for more than 18V.